Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-07-09 11:21:26
Exec Total Coverage
Lines: 1756 4160 42.2%
Functions: 131 329 39.8%
Branches: 935 2686 34.8%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 #include <math.h>
18 #include <map>
19 #include <filesystem>
20 #include <ctype.h>
21 #include <sstream>
22 #include "base/zc_alleg.h"
23 #include "gamedata.h"
24 #include "zc/zc_init.h"
25 #include "init.h"
26 #include "zc/replay.h"
27 #include "zc/cheats.h"
28 #include "zc/render.h"
29 #include "base/zc_math.h"
30 #include "base/zapp.h"
31 #include "dialog/cheatkeys.h"
32 #include "metadata/metadata.h"
33 #include "zc/zelda.h"
34 #include "tiles.h"
35 #include "base/colors.h"
36 #include "pal.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 #include "zc/zc_sys.h"
40 #include "play_midi.h"
41 #include "jwin_a5.h"
42 #include "base/jwinfsel.h"
43 #include "base/gui.h"
44 #include "midi.h"
45 #include "subscr.h"
46 #include "zc/maps.h"
47 #include "sprite.h"
48 #include "zc/guys.h"
49 #include "zc/hero.h"
50 #include "zc/title.h"
51 #include "particles.h"
52 #include "zconsole.h"
53 #include "zc/ffscript.h"
54 #include "dialog/info.h"
55 #include "dialog/alert.h"
56 #include "zc/combos.h"
57 #include <fmt/format.h>
58
59 #ifdef __EMSCRIPTEN__
60 #include "base/emscripten_utils.h"
61 #endif
62
63 extern FFScript FFCore;
64 extern bool Playing;
65 int32_t sfx_voice[WAV_COUNT];
66 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
67 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
68
69 extern byte monochrome_console;
70
71 extern HeroClass Hero;
72 extern FFScript FFCore;
73 extern ZModule zcm;
74 extern zcmodule moduledata;
75 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
76 extern particle_list particles;
77 extern int32_t loadlast;
78 extern char *sfx_string[WAV_COUNT];
79 byte use_dwm_flush;
80 byte use_save_indicator;
81 byte midi_patch_fix;
82 bool midi_paused=false;
83 int32_t paused_midi_pos = 0;
84 byte midi_suspended = 0;
85 byte callback_switchin = 0;
86 byte zc_192b163_warp_compatibility;
87 char modulepath[2048];
88 bool epilepsyFlashReduction;
89 signed char pause_in_background_menu_init = 0;
90 byte pause_in_background = 0;
91 bool is_sys_pal = false;
92 static bool load_control_called_this_frame;
93 extern PALETTE* hw_palette;
94 extern bool update_hw_pal;
95 extern const char* dmaplist(int32_t index, int32_t* list_size);
96 int32_t getnumber(const char *prompt,int32_t initialval);
97
98 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
99 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
100 //extern byte refresh_select_screen;
101 //extern movingblock mblock2; //mblock[4]?
102 //extern int32_t db;
103
104 static const char *ZC_str = "Zelda Classic";
105 extern char save_file_name[1024];
106 #if defined(ALLEGRO_WINDOWS)
107 const char *qst_dir_name = "win_qst_dir";
108 static const char *qst_module_name = "current_module";
109 #elif defined(ALLEGRO_LINUX)
110 const char *qst_dir_name = "linux_qst_dir";
111 static const char *qst_module_name = "current_module";
112 #elif defined(__APPLE__)
113 const char *qst_dir_name = "osx_qst_dir";
114 static const char *qst_module_name = "current_module";
115 #endif
116 #ifdef ALLEGRO_LINUX
117 static const char *samplepath = "samplesoundset/patches.dat";
118 #endif
119 char qst_files_path[2048];
120
121 #ifdef _MSC_VER
122 #define getcwd _getcwd
123 #endif
124
125 bool rF11();
126 bool rI();
127 bool rQ();
128 bool zc_key_pressed();
129
130 #ifdef _WIN32
131
132 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
133 extern "C"
134 {
135 typedef HRESULT(WINAPI *t_DwmFlush)();
136 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
137 }
138
139 void do_DwmFlush()
140 {
141 static HMODULE shell = LoadLibrary("dwmapi.dll");
142
143 if(!shell)
144 return;
145
146 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
147 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
148
149 BOOL enabled;
150 isEnabled(&enabled);
151
152 if(isEnabled)
153 flush();
154 }
155
156 #endif // _WIN32
157
158 82835 bool flash_reduction_enabled(bool check_qr)
159 {
160
4/4
✓ Branch 0 taken 80614 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 80158 times.
✓ Branch 3 taken 82379 times.
82835 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
161 }
162
163 // Dialogue largening
164 void large_dialog(DIALOG *d)
165 {
166 large_dialog(d, 1.5);
167 }
168
169 void large_dialog(DIALOG *d, float RESIZE_AMT)
170 {
171 if(!d[0].d1)
172 {
173 d[0].d1 = 1;
174 int32_t oldwidth = d[0].w;
175 int32_t oldheight = d[0].h;
176 int32_t oldx = d[0].x;
177 int32_t oldy = d[0].y;
178 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
179 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
180 d[0].w = int32_t(d[0].w*RESIZE_AMT);
181 d[0].h = int32_t(d[0].h*RESIZE_AMT);
182
183 for(int32_t i=1; d[i].proc !=NULL; i++)
184 {
185 // Place elements horizontally
186 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
187 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
188
189 if(d[i].proc != d_stringloader)
190 {
191 if(d[i].proc==d_bitmap_proc)
192 {
193 d[i].w *= 2;
194 }
195 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
196 }
197
198 // Place elements vertically
199 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
200 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
201
202 // Vertically resize elements
203 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
204 {
205 d[i].h = int32_t((double)d[i].h*1.5);
206 }
207 else if(d[i].proc == jwin_droplist_proc)
208 {
209 d[i].y += int32_t((double)d[i].h*0.25);
210 d[i].h = int32_t((double)d[i].h*1.25);
211 }
212 else if(d[i].proc==d_bitmap_proc)
213 {
214 d[i].h *= 2;
215 }
216 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
217
218 // Fix frames
219 if(d[i].proc == jwin_frame_proc)
220 {
221 d[i].x++;
222 d[i].y++;
223 d[i].w-=4;
224 d[i].h-=4;
225 }
226 }
227 }
228
229 for(int32_t i=1; d[i].proc!=NULL; i++)
230 {
231 if(d[i].proc==jwin_slider_proc)
232 continue;
233
234 // Bigger font
235 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
236
237 if(!d[i].dp2 && bigfontproc)
238 {
239 d[i].dp2 = get_zc_font(font_lfont_l);
240 }
241 else if(!bigfontproc)
242 {
243 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
244 }
245
246 // Make checkboxes work
247 if(d[i].proc == jwin_check_proc)
248 d[i].proc = jwin_checkfont_proc;
249 else if(d[i].proc == jwin_radio_proc)
250 d[i].proc = jwin_radiofont_proc;
251 }
252
253 jwin_center_dialog(d);
254 }
255
256
257 /**********************************/
258 /******** System functions ********/
259 /**********************************/
260
261 static char cfg_sect[] = "zeldadx"; //We need to rename this.
262 static char ctrl_sect[] = "Controls";
263 static char sfx_sect[] = "Volume";
264
265 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
266 {
267 return D_O_K;
268 }
269
270 bool is_reserved_key(int c)
271 {
272 switch(c)
273 {
274 case KEY_ESC:
275 return true;
276 }
277 return false;
278 }
279 bool is_reserved_keycombo(int c, int modflag)
280 {
281 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
282 return true;
283 return false;
284 }
285 bool checkcheat(Cheat cheat)
286 {
287 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
288 return true; //Main key pressed
289 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
290 return true; //Alt key pressed
291 return false;
292 }
293 39 void load_default_cheatkeys()
294 {
295 39 memset(cheatkeys, 0, sizeof(cheatkeys));
296 39 cheatkeys[Cheat::Life][0] = KEY_H;
297 39 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
298 39 cheatkeys[Cheat::Magic][0] = KEY_M;
299 39 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
300 39 cheatkeys[Cheat::Rupies][0] = KEY_R;
301 39 cheatkeys[Cheat::Bombs][0] = KEY_B;
302 39 cheatkeys[Cheat::Arrows][0] = KEY_A;
303 39 cheatkeys[Cheat::Clock][0] = KEY_I;
304 39 cheatkeys[Cheat::Walls][0] = KEY_F11;
305 39 cheatkeys[Cheat::Fast][0] = KEY_Q;
306 39 cheatkeys[Cheat::Light][0] = KEY_L;
307 39 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
308 39 cheatkeys[Cheat::Kill][0] = KEY_K;
309 39 cheatkeys[Cheat::GoTo][0] = KEY_G;
310 39 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
311 39 cheatkeys[Cheat::ShowL0][0] = KEY_0;
312 39 cheatkeys[Cheat::ShowL1][0] = KEY_1;
313 39 cheatkeys[Cheat::ShowL2][0] = KEY_2;
314 39 cheatkeys[Cheat::ShowL3][0] = KEY_3;
315 39 cheatkeys[Cheat::ShowL4][0] = KEY_4;
316 39 cheatkeys[Cheat::ShowL5][0] = KEY_5;
317 39 cheatkeys[Cheat::ShowL6][0] = KEY_6;
318 39 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
319 39 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
320 39 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
321 39 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
322 39 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
323 39 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
324 39 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
325 39 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
326 39 }
327 39 void load_game_configs()
328 {
329 39 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
330 39 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
331 39 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
332 39 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
333 39 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
334 39 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
335 39 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
336 39 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
337 39 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
338 39 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
339 39 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
340 39 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
341 39 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
342 39 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
343 39 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
344
345 //cheat modifier keya
346 39 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
347 39 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
348 39 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
349 39 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
350
351 //cheat keys
352 39 load_default_cheatkeys();
353 char buf[256];
354
2/2
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 39 times.
1404 for(size_t q = 1; q < Cheat::Last; ++q)
355 {
356
1/2
✓ Branch 0 taken 1365 times.
✗ Branch 1 not taken.
1365 if(!bindable_cheat((Cheat)q)) continue;
357 1365 std::string cheatname = cheat_to_string((Cheat)q);
358
1/2
✓ Branch 0 taken 1365 times.
✗ Branch 1 not taken.
1365 util::lowerstr(cheatname);
359 1365 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
360
1/2
✓ Branch 0 taken 1365 times.
✗ Branch 1 not taken.
1365 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
361 1365 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1365 times.
✗ Branch 1 not taken.
1365 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
363 1365 }
364
365
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
366 joystick_index = 0;
367
368 39 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
369 39 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
370 39 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
371 39 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
372 39 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
373 39 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
374 39 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
375 39 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
376 39 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
377 39 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
378
379 39 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
380 39 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
381 39 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
382 39 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
383
384 39 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
385 39 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
386 39 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
387 39 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
388 39 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
389 39 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
390 39 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
391 39 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
392 39 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
393 39 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
394 39 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
395
396 39 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
397 39 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
398 39 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
399 39 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
400
401 39 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
402
403 39 digi_volume = zc_get_config(sfx_sect,"digi",248);
404 39 midi_volume = zc_get_config(sfx_sect,"midi",255);
405 39 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
406 39 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
407 39 pan_style = zc_get_config(sfx_sect,"pan",1);
408 // 1 <= zcmusic_bufsz <= 128
409 39 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
410 39 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
411 39 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
412 39 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
413 39 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
414 39 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
415 39 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
416 #ifdef __EMSCRIPTEN__
417 if (em_is_mobile()) NameEntryMode = 2;
418 #endif
419 39 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
420 39 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
421 39 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
422 39 title_version = zc_get_config(cfg_sect,"title",2);
423 39 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
424 39 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
425
426 //default - scale x2, 640 x 480
427 39 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
428 39 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
429 39 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
430 39 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
431 39 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
432 39 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
433 39 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
434
435 39 loadlast = zc_get_config(cfg_sect,"load_last",0);
436
437 39 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
438
439 39 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
440
441 39 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
442 39 info_opacity = zc_get_config("zc","debug_info_opacity",255);
443 #ifdef _WIN32
444 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
445 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
446 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
447 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
448
449 // This one's for Aero
450 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
451
452 // And this one fixes patches unloading on some MIDI setups
453 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
454 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
455 #else //UNIX
456 39 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
457 39 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
458 39 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
459 #endif
460 39 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
461 39 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
462
463 39 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
464
465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(strlen(qstdir)==0)
466 {
467 39 getcwd(qstdir,2048);
468 39 fix_filename_case(qstdir);
469 39 fix_filename_slashes(qstdir);
470 39 put_backslash(qstdir);
471 39 }
472 else
473 {
474 chop_path(qstdir);
475 }
476
477 39 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
478 39 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
479 39 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
480 39 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
481 39 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
482 39 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
483 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
484 39 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
485 39 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
486 39 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
487 39 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
488 39 }
489
490 void save_control_configs(bool kb)
491 {
492 if(kb)
493 {
494 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
495 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
496 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
497 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
498
499 if (!replay_is_replaying())
500 {
501 zc_set_config(ctrl_sect,"key_a",Akey);
502 zc_set_config(ctrl_sect,"key_b",Bkey);
503 zc_set_config(ctrl_sect,"key_s",Skey);
504 zc_set_config(ctrl_sect,"key_l",Lkey);
505 zc_set_config(ctrl_sect,"key_r",Rkey);
506 zc_set_config(ctrl_sect,"key_p",Pkey);
507 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
508 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
509 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
510 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
511 zc_set_config(ctrl_sect,"key_up", DUkey);
512 zc_set_config(ctrl_sect,"key_down", DDkey);
513 zc_set_config(ctrl_sect,"key_left", DLkey);
514 zc_set_config(ctrl_sect,"key_right",DRkey);
515 }
516 }
517 else
518 {
519 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
520 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
521 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
522 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
523 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
524 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
525 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
526 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
527 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
528 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
529 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
530 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
531 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
532 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
533
534 zc_set_config(ctrl_sect,"btn_a",Abtn);
535 zc_set_config(ctrl_sect,"btn_b",Bbtn);
536 zc_set_config(ctrl_sect,"btn_s",Sbtn);
537 zc_set_config(ctrl_sect,"btn_m",Mbtn);
538 zc_set_config(ctrl_sect,"btn_l",Lbtn);
539 zc_set_config(ctrl_sect,"btn_r",Rbtn);
540 zc_set_config(ctrl_sect,"btn_p",Pbtn);
541 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
542 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
543 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
544 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
545
546 zc_set_config(ctrl_sect,"btn_up",DUbtn);
547 zc_set_config(ctrl_sect,"btn_down",DDbtn);
548 zc_set_config(ctrl_sect,"btn_left",DLbtn);
549 zc_set_config(ctrl_sect,"btn_right",DRbtn);
550 }
551 }
552
553 void save_cheatkeys()
554 {
555 char buf[256];
556 for(size_t q = 1; q < Cheat::Last; ++q)
557 {
558 if(!bindable_cheat((Cheat)q)) continue;
559 std::string cheatname = cheat_to_string((Cheat)q);
560 util::lowerstr(cheatname);
561 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
562 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
563 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
564 if(cheatkeys[q][1])
565 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
566 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
567 }
568 }
569
570 void save_game_configs()
571 {
572 packfile_password("");
573
574 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
575
576 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
577 {
578 int o_window_x, o_window_y;
579 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
580 zc_set_config(cfg_sect,"window_x",o_window_x);
581 zc_set_config(cfg_sect,"window_y",o_window_y);
582 }
583
584 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
585 {
586 double monitor_scale = zc_get_monitor_scale();
587 window_width = al_get_display_width(all_get_display()) / monitor_scale;
588 window_height = al_get_display_height(all_get_display()) / monitor_scale;
589 zc_set_config(cfg_sect,"window_width",window_width);
590 zc_set_config(cfg_sect,"window_height",window_height);
591 }
592
593 zc_set_config(cfg_sect,"load_last",loadlast);
594 chop_path(qstdir);
595 zc_set_config(cfg_sect,qst_dir_name,qstdir);
596 zc_set_config("SAVEFILE","save_filename",save_file_name);
597 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
598
599 flush_config_file();
600 #ifdef __EMSCRIPTEN__
601 em_sync_fs();
602 #endif
603 }
604
605 //----------------------------------------------------------------
606
607 // Timers
608
609 29511 void fps_callback()
610 {
611 29511 lastfps=framecnt;
612 29511 dword tempsecs = fps_secs;
613 29511 ++tempsecs;
614 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
615 29511 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
616 29511 ++fps_secs;
617 29511 framecnt=0;
618 29511 }
619
620 END_OF_FUNCTION(fps_callback)
621
622 39 int32_t Z_init_timers()
623 {
624 static bool didit = false;
625 const static char *err_str = "Couldn't allocate timer";
626 39 err_str = err_str; //Unused variable warning
627
628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(didit)
629 return 1;
630
631 39 didit = true;
632
633 LOCK_VARIABLE(lastfps);
634 LOCK_VARIABLE(framecnt);
635 LOCK_FUNCTION(fps_callback);
636
637
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
638 return 0;
639
640 39 return 1;
641 39 }
642
643 void Z_remove_timers()
644 {
645 remove_int(fps_callback);
646 }
647
648 //----------------------------------------------------------------
649
650 void go()
651 {
652 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
653 }
654
655 void comeback()
656 {
657 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
658 }
659
660 void dump_pal(BITMAP *dest)
661 {
662 for(int32_t i=0; i<256; i++)
663 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
664 }
665
666 //----------------------------------------------------------------
667
668 int game_mouse_index = ZCM_BLANK;
669 static bool system_mouse = false;
670 104 bool sys_mouse()
671 {
672 104 system_mouse = true;
673 104 return MouseSprite::set(ZCM_NORMAL);
674 }
675 472 bool game_mouse()
676 {
677 472 system_mouse = false;
678 472 return MouseSprite::set(game_mouse_index);
679 }
680 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
681 {
682 if(!bmp)
683 return;
684 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
685 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
686 if(bmp->w == scaledw && bmp->h == scaledh)
687 user_scale = false;
688 if(user_scale || sys_recolor)
689 {
690 if(!user_scale) scale = 1;
691 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
692 if(user_scale)
693 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
694 else
695 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
696 if(sys_recolor)
697 recolor_mouse(tmpbmp);
698 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
699 destroy_bitmap(tmpbmp);
700 }
701 else
702 {
703 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
704 }
705 }
706
707 //Handles converting the mouse sprite from the .dat file
708 39 void recolor_mouse(BITMAP* bmp)
709 {
710
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 39 times.
663 for(int32_t x = 0; x < bmp->w; ++x)
711 {
712
2/2
✓ Branch 0 taken 9984 times.
✓ Branch 1 taken 624 times.
10608 for(int32_t y = 0; y < bmp->h; ++y)
713 {
714 9984 int32_t color = getpixel(bmp, x, y);
715
5/5
✓ Branch 0 taken 6786 times.
✓ Branch 1 taken 741 times.
✓ Branch 2 taken 858 times.
✓ Branch 3 taken 897 times.
✓ Branch 4 taken 702 times.
9984 switch(color)
716 {
717 case dvc(1):
718 741 color = jwin_pal[jcCURSORMISC];
719 741 break;
720 case dvc(2):
721 858 color = jwin_pal[jcCURSOROUTLINE];
722 858 break;
723 case dvc(3):
724 897 color = jwin_pal[jcCURSORLIGHT];
725 897 break;
726 case dvc(5):
727 702 color = jwin_pal[jcCURSORDARK];
728 702 break;
729 default:
730 6786 continue;
731 }
732 3198 putpixel(bmp, x, y, color);
733 3198 }
734 624 }
735 39 }
736 39 void load_mouse()
737 {
738 39 enter_sys_pal();
739 39 MouseSprite::set(-1);
740 39 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
741 39 int32_t sz = 16*scale;
742
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 39 times.
78 for(int32_t j = 0; j < 1; ++j)
743 {
744 39 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
745
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(zcmouse[j])
746 destroy_bitmap(zcmouse[j]);
747 39 zcmouse[j] = create_bitmap_ex(8,sz,sz);
748 39 clear_bitmap(zcmouse[j]);
749 39 clear_bitmap(tmpbmp);
750 39 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
751 39 recolor_mouse(tmpbmp);
752
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(sz!=16)
753 39 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
754 else
755 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
756 39 destroy_bitmap(tmpbmp);
757 39 }
758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(!hw_palette) hw_palette = &RAMpal;
759 39 zc_set_palette(*hw_palette);
760
761 39 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
762 39 clear_bitmap(blankmouse);
763
764 39 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
765 39 MouseSprite::assign(ZCM_BLANK, blankmouse);
766 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
767
768 //Reload the mouse
769
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(system_mouse)
770 39 sys_mouse();
771 else game_mouse();
772
773 39 destroy_bitmap(blankmouse);
774 39 exit_sys_pal();
775 39 }
776
777 // sets the video mode and initializes the palette and mouse sprite
778 39 bool game_vid_mode(int32_t mode,int32_t wait)
779 {
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
781 {
782 return false;
783 }
784
785 39 scrx = (resx-320)>>1;
786 39 scry = (resy-240)>>1;
787
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 39 times.
78 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
788 39 zcmouse[q] = NULL;
789 39 load_mouse();
790
791
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 39 times.
663 for(int32_t i=240; i<256; i++)
792 624 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
793
794 39 zc_set_palette(RAMpal);
795 39 clear_to_color(screen,BLACK);
796
797 39 rest(wait);
798 39 return true;
799 39 }
800
801 8 void null_quest()
802 {
803 char qstdat_string[2048];
804 8 strcpy(qstdat_string, "modules/classic/default.qst");
805
806 #ifdef __EMSCRIPTEN__
807 // The quest template data file is not included because it's really big and isn't really needed
808 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
809 // which is much smaller.
810 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
811 #endif
812
813 8 byte skip_flags[4] = { 0 };
814
815 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,skip_flags,0,false);
816 8 }
817
818 // TODO remove
819 8 void init_NES_mode()
820 {
821 8 null_quest();
822 8 }
823
824 //----------------------------------------------------------------
825
826 qword trianglelines[16]=
827 {
828 0x0000000000000000ULL,
829 0xFD00000000000000ULL,
830 0xFDFD000000000000ULL,
831 0xFDFDFD0000000000ULL,
832 0xFDFDFDFD00000000ULL,
833 0xFDFDFDFDFD000000ULL,
834 0xFDFDFDFDFDFD0000ULL,
835 0xFDFDFDFDFDFDFD00ULL,
836 0xFDFDFDFDFDFDFDFDULL,
837 0x00FDFDFDFDFDFDFDULL,
838 0x0000FDFDFDFDFDFDULL,
839 0x000000FDFDFDFDFDULL,
840 0x00000000FDFDFDFDULL,
841 0x0000000000FDFDFDULL,
842 0x000000000000FDFDULL,
843 0x00000000000000FDULL,
844 };
845
846 word screen_triangles[28][32];
847 /*
848 qword triangles[4][16]= //[direction][value]
849 {
850 {
851 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
852 },
853 {
854 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
855 },
856 {
857 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
858 },
859 {
860 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
861 }
862 };
863 */
864
865
866 /*
867 byte triangles[4][16][8]= //[direction][value][line]
868 {
869 {
870 {
871 0, 0, 0, 0, 0, 0, 0, 0
872 },
873 {
874 1, 0, 0, 0, 0, 0, 0, 0
875 },
876 {
877 2, 1, 0, 0, 0, 0, 0, 0
878 },
879 {
880 3, 2, 1, 0, 0, 0, 0, 0
881 },
882 {
883 4, 3, 2, 1, 0, 0, 0, 0
884 },
885 {
886 5, 4, 3, 2, 1, 0, 0, 0
887 },
888 {
889 6, 5, 4, 3, 2, 1, 0, 0
890 },
891 {
892 7, 6, 5, 4, 3, 2, 1, 0
893 },
894 {
895 8, 7, 6, 5, 4, 3, 2, 1
896 },
897 {
898 8, 8, 7, 6, 5, 4, 3, 2
899 },
900 {
901 8, 8, 8, 7, 6, 5, 4, 3
902 },
903 {
904 8, 8, 8, 8, 7, 6, 5, 4
905 },
906 {
907 8, 8, 8, 8, 8, 7, 6, 5
908 },
909 {
910 8, 8, 8, 8, 8, 8, 7, 6
911 },
912 {
913 8, 8, 8, 8, 8, 8, 8, 7
914 },
915 {
916 8, 8, 8, 8, 8, 8, 8, 8
917 }
918 },
919 {
920 {
921 0, 0, 0, 0, 0, 0, 0, 0
922 },
923 {
924 15, 0, 0, 0, 0, 0, 0, 0
925 },
926 {
927 14, 15, 0, 0, 0, 0, 0, 0
928 },
929 {
930 13, 14, 15, 0, 0, 0, 0, 0
931 },
932 {
933 12, 13, 14, 15, 0, 0, 0, 0
934 },
935 {
936 11, 12, 13, 14, 15, 0, 0, 0
937 },
938 {
939 10, 11, 12, 13, 14, 15, 0, 0
940 },
941 {
942 9, 10, 11, 12, 13, 14, 15, 0
943 },
944 {
945 8, 9, 10, 11, 12, 13, 14, 15
946 },
947 {
948 8, 8, 9, 10, 11, 12, 13, 14
949 },
950 {
951 8, 8, 8, 9, 10, 11, 12, 13
952 },
953 {
954 8, 8, 8, 8, 9, 10, 11, 12
955 },
956 {
957 8, 8, 8, 8, 8, 9, 10, 11
958 },
959 {
960 8, 8, 8, 8, 8, 8, 9, 10
961 },
962 {
963 8, 8, 8, 8, 8, 8, 8, 9
964 },
965 {
966 8, 8, 8, 8, 8, 8, 8, 8
967 }
968 },
969 {
970 {
971 0, 0, 0, 0, 0, 0, 0, 0
972 },
973 {
974 0, 0, 0, 0, 0, 0, 0, 1
975 },
976 {
977 0, 0, 0, 0, 0, 0, 1, 2
978 },
979 {
980 0, 0, 0, 0, 0, 1, 2, 3
981 },
982 {
983 0, 0, 0, 0, 1, 2, 3, 4
984 },
985 {
986 0, 0, 0, 1, 2, 3, 4, 5
987 },
988 {
989 0, 0, 1, 2, 3, 4, 5, 6
990 },
991 {
992 0, 1, 2, 3, 4, 5, 6, 7
993 },
994 {
995 1, 2, 3, 4, 5, 6, 7, 8
996 },
997 {
998 2, 3, 4, 5, 6, 7, 8, 8
999 },
1000 {
1001 3, 4, 5, 6, 7, 8, 8, 8
1002 },
1003 {
1004 4, 5, 6, 7, 8, 8, 8, 8
1005 },
1006 {
1007 5, 6, 7, 8, 8, 8, 8, 8
1008 },
1009 {
1010 6, 7, 8, 8, 8, 8, 8, 8
1011 },
1012 {
1013 7, 8, 8, 8, 8, 8, 8, 8
1014 },
1015 {
1016 8, 8, 8, 8, 8, 8, 8, 8
1017 }
1018 },
1019 {
1020 {
1021 0, 0, 0, 0, 0, 0, 0, 0
1022 },
1023 {
1024 0, 0, 0, 0, 0, 0, 0, 15
1025 },
1026 {
1027 0, 0, 0, 0, 0, 0, 15, 14
1028 },
1029 {
1030 0, 0, 0, 0, 0, 15, 14, 13
1031 },
1032 {
1033 0, 0, 0, 0, 15, 14, 13, 12
1034 },
1035 {
1036 0, 0, 0, 15, 14, 13, 12, 11
1037 },
1038 {
1039 0, 0, 15, 14, 13, 12, 11, 10
1040 },
1041 {
1042 0, 15, 14, 13, 12, 11, 10, 9
1043 },
1044 {
1045 15, 14, 13, 12, 11, 10, 9, 8
1046 },
1047 {
1048 14, 13, 12, 11, 10, 9, 8, 8
1049 },
1050 {
1051 13, 12, 11, 10, 9, 8, 8, 8
1052 },
1053 {
1054 12, 11, 10, 9, 8, 8, 8, 8
1055 },
1056 {
1057 11, 10, 9, 8, 8, 8, 8, 8
1058 },
1059 {
1060 10, 9, 8, 8, 8, 8, 8, 8
1061 },
1062 {
1063 9, 8, 8, 8, 8, 8, 8, 8
1064 },
1065 {
1066 8, 8, 8, 8, 8, 8, 8, 8
1067 }
1068 }
1069 };
1070 */
1071
1072
1073
1074 /*
1075 for (int32_t blockrow=0; blockrow<30; ++i)
1076 {
1077 for (int32_t linerow=0; linerow<8; ++i)
1078 {
1079 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1080 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1081 {
1082 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1083 ++triangleline;
1084 }
1085 }
1086 }
1087 */
1088
1089 // the ULL suffixes are to prevent this warning:
1090 // warning: integer constant is too large for "int32_t" type
1091
1092 qword triangles[4][16][8]= //[direction][value][line]
1093 {
1094 {
1095 {
1096 0x0000000000000000ULL,
1097 0x0000000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL
1104 },
1105 {
1106 0xFD00000000000000ULL,
1107 0x0000000000000000ULL,
1108 0x0000000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL
1114 },
1115 {
1116 0xFDFD000000000000ULL,
1117 0xFD00000000000000ULL,
1118 0x0000000000000000ULL,
1119 0x0000000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL
1124 },
1125 {
1126 0xFDFDFD0000000000ULL,
1127 0xFDFD000000000000ULL,
1128 0xFD00000000000000ULL,
1129 0x0000000000000000ULL,
1130 0x0000000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL
1134 },
1135 {
1136 0xFDFDFDFD00000000ULL,
1137 0xFDFDFD0000000000ULL,
1138 0xFDFD000000000000ULL,
1139 0xFD00000000000000ULL,
1140 0x0000000000000000ULL,
1141 0x0000000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL
1144 },
1145 {
1146 0xFDFDFDFDFD000000ULL,
1147 0xFDFDFDFD00000000ULL,
1148 0xFDFDFD0000000000ULL,
1149 0xFDFD000000000000ULL,
1150 0xFD00000000000000ULL,
1151 0x0000000000000000ULL,
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL
1154 },
1155 {
1156 0xFDFDFDFDFDFD0000ULL,
1157 0xFDFDFDFDFD000000ULL,
1158 0xFDFDFDFD00000000ULL,
1159 0xFDFDFD0000000000ULL,
1160 0xFDFD000000000000ULL,
1161 0xFD00000000000000ULL,
1162 0x0000000000000000ULL,
1163 0x0000000000000000ULL
1164 },
1165 {
1166 0xFDFDFDFDFDFDFD00ULL,
1167 0xFDFDFDFDFDFD0000ULL,
1168 0xFDFDFDFDFD000000ULL,
1169 0xFDFDFDFD00000000ULL,
1170 0xFDFDFD0000000000ULL,
1171 0xFDFD000000000000ULL,
1172 0xFD00000000000000ULL,
1173 0x0000000000000000ULL
1174 },
1175 {
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFD00ULL,
1178 0xFDFDFDFDFDFD0000ULL,
1179 0xFDFDFDFDFD000000ULL,
1180 0xFDFDFDFD00000000ULL,
1181 0xFDFDFD0000000000ULL,
1182 0xFDFD000000000000ULL,
1183 0xFD00000000000000ULL
1184 },
1185 {
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFD00ULL,
1189 0xFDFDFDFDFDFD0000ULL,
1190 0xFDFDFDFDFD000000ULL,
1191 0xFDFDFDFD00000000ULL,
1192 0xFDFDFD0000000000ULL,
1193 0xFDFD000000000000ULL
1194 },
1195 {
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFD00ULL,
1200 0xFDFDFDFDFDFD0000ULL,
1201 0xFDFDFDFDFD000000ULL,
1202 0xFDFDFDFD00000000ULL,
1203 0xFDFDFD0000000000ULL
1204 },
1205 {
1206 0xFDFDFDFDFDFDFDFDULL,
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFD00ULL,
1211 0xFDFDFDFDFDFD0000ULL,
1212 0xFDFDFDFDFD000000ULL,
1213 0xFDFDFDFD00000000ULL
1214 },
1215 {
1216 0xFDFDFDFDFDFDFDFDULL,
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFD00ULL,
1222 0xFDFDFDFDFDFD0000ULL,
1223 0xFDFDFDFDFD000000ULL
1224 },
1225 {
1226 0xFDFDFDFDFDFDFDFDULL,
1227 0xFDFDFDFDFDFDFDFDULL,
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFD00ULL,
1233 0xFDFDFDFDFDFD0000ULL
1234 },
1235 {
1236 0xFDFDFDFDFDFDFDFDULL,
1237 0xFDFDFDFDFDFDFDFDULL,
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFD00ULL
1244 },
1245 {
1246 0xFDFDFDFDFDFDFDFDULL,
1247 0xFDFDFDFDFDFDFDFDULL,
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL
1254 }
1255 },
1256 {
1257 {
1258 0x0000000000000000ULL,
1259 0x0000000000000000ULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL
1266 },
1267 {
1268 0x00000000000000FDULL,
1269 0x0000000000000000ULL,
1270 0x0000000000000000ULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL
1276 },
1277 {
1278 0x000000000000FDFDULL,
1279 0x00000000000000FDULL,
1280 0x0000000000000000ULL,
1281 0x0000000000000000ULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL
1286 },
1287 {
1288 0x0000000000FDFDFDULL,
1289 0x000000000000FDFDULL,
1290 0x00000000000000FDULL,
1291 0x0000000000000000ULL,
1292 0x0000000000000000ULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL
1296 },
1297 {
1298 0x00000000FDFDFDFDULL,
1299 0x0000000000FDFDFDULL,
1300 0x000000000000FDFDULL,
1301 0x00000000000000FDULL,
1302 0x0000000000000000ULL,
1303 0x0000000000000000ULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL
1306 },
1307 {
1308 0x000000FDFDFDFDFDULL,
1309 0x00000000FDFDFDFDULL,
1310 0x0000000000FDFDFDULL,
1311 0x000000000000FDFDULL,
1312 0x00000000000000FDULL,
1313 0x0000000000000000ULL,
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL
1316 },
1317 {
1318 0x0000FDFDFDFDFDFDULL,
1319 0x000000FDFDFDFDFDULL,
1320 0x00000000FDFDFDFDULL,
1321 0x0000000000FDFDFDULL,
1322 0x000000000000FDFDULL,
1323 0x00000000000000FDULL,
1324 0x0000000000000000ULL,
1325 0x0000000000000000ULL
1326 },
1327 {
1328 0x00FDFDFDFDFDFDFDULL,
1329 0x0000FDFDFDFDFDFDULL,
1330 0x000000FDFDFDFDFDULL,
1331 0x00000000FDFDFDFDULL,
1332 0x0000000000FDFDFDULL,
1333 0x000000000000FDFDULL,
1334 0x00000000000000FDULL,
1335 0x0000000000000000ULL
1336 },
1337 {
1338 0xFDFDFDFDFDFDFDFDULL,
1339 0x00FDFDFDFDFDFDFDULL,
1340 0x0000FDFDFDFDFDFDULL,
1341 0x000000FDFDFDFDFDULL,
1342 0x00000000FDFDFDFDULL,
1343 0x0000000000FDFDFDULL,
1344 0x000000000000FDFDULL,
1345 0x00000000000000FDULL
1346 },
1347 {
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0x00FDFDFDFDFDFDFDULL,
1351 0x0000FDFDFDFDFDFDULL,
1352 0x000000FDFDFDFDFDULL,
1353 0x00000000FDFDFDFDULL,
1354 0x0000000000FDFDFDULL,
1355 0x000000000000FDFDULL
1356 },
1357 {
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0x00FDFDFDFDFDFDFDULL,
1362 0x0000FDFDFDFDFDFDULL,
1363 0x000000FDFDFDFDFDULL,
1364 0x00000000FDFDFDFDULL,
1365 0x0000000000FDFDFDULL
1366 },
1367 {
1368 0xFDFDFDFDFDFDFDFDULL,
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0x00FDFDFDFDFDFDFDULL,
1373 0x0000FDFDFDFDFDFDULL,
1374 0x000000FDFDFDFDFDULL,
1375 0x00000000FDFDFDFDULL
1376 },
1377 {
1378 0xFDFDFDFDFDFDFDFDULL,
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0x00FDFDFDFDFDFDFDULL,
1384 0x0000FDFDFDFDFDFDULL,
1385 0x000000FDFDFDFDFDULL
1386 },
1387 {
1388 0xFDFDFDFDFDFDFDFDULL,
1389 0xFDFDFDFDFDFDFDFDULL,
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0x00FDFDFDFDFDFDFDULL,
1395 0x0000FDFDFDFDFDFDULL
1396 },
1397 {
1398 0xFDFDFDFDFDFDFDFDULL,
1399 0xFDFDFDFDFDFDFDFDULL,
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0x00FDFDFDFDFDFDFDULL
1406 },
1407 {
1408 0xFDFDFDFDFDFDFDFDULL,
1409 0xFDFDFDFDFDFDFDFDULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL
1416 }
1417 },
1418 {
1419 {
1420 0x0000000000000000ULL,
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL
1428 },
1429 {
1430 0x0000000000000000ULL,
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0xFD00000000000000ULL
1438 },
1439 {
1440 0x0000000000000000ULL,
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0xFD00000000000000ULL,
1447 0xFDFD000000000000ULL
1448 },
1449 {
1450 0x0000000000000000ULL,
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0xFD00000000000000ULL,
1456 0xFDFD000000000000ULL,
1457 0xFDFDFD0000000000ULL
1458 },
1459 {
1460 0x0000000000000000ULL,
1461 0x0000000000000000ULL,
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0xFD00000000000000ULL,
1465 0xFDFD000000000000ULL,
1466 0xFDFDFD0000000000ULL,
1467 0xFDFDFDFD00000000ULL
1468 },
1469 {
1470 0x0000000000000000ULL,
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0xFD00000000000000ULL,
1474 0xFDFD000000000000ULL,
1475 0xFDFDFD0000000000ULL,
1476 0xFDFDFDFD00000000ULL,
1477 0xFDFDFDFDFD000000ULL
1478 },
1479 {
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0xFD00000000000000ULL,
1483 0xFDFD000000000000ULL,
1484 0xFDFDFD0000000000ULL,
1485 0xFDFDFDFD00000000ULL,
1486 0xFDFDFDFDFD000000ULL,
1487 0xFDFDFDFDFDFD0000ULL
1488 },
1489 {
1490 0x0000000000000000ULL,
1491 0xFD00000000000000ULL,
1492 0xFDFD000000000000ULL,
1493 0xFDFDFD0000000000ULL,
1494 0xFDFDFDFD00000000ULL,
1495 0xFDFDFDFDFD000000ULL,
1496 0xFDFDFDFDFDFD0000ULL,
1497 0xFDFDFDFDFDFDFD00ULL
1498 },
1499 {
1500 0xFD00000000000000ULL,
1501 0xFDFD000000000000ULL,
1502 0xFDFDFD0000000000ULL,
1503 0xFDFDFDFD00000000ULL,
1504 0xFDFDFDFDFD000000ULL,
1505 0xFDFDFDFDFDFD0000ULL,
1506 0xFDFDFDFDFDFDFD00ULL,
1507 0xFDFDFDFDFDFDFDFDULL
1508 },
1509 {
1510 0xFDFD000000000000ULL,
1511 0xFDFDFD0000000000ULL,
1512 0xFDFDFDFD00000000ULL,
1513 0xFDFDFDFDFD000000ULL,
1514 0xFDFDFDFDFDFD0000ULL,
1515 0xFDFDFDFDFDFDFD00ULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL
1518 },
1519 {
1520 0xFDFDFD0000000000ULL,
1521 0xFDFDFDFD00000000ULL,
1522 0xFDFDFDFDFD000000ULL,
1523 0xFDFDFDFDFDFD0000ULL,
1524 0xFDFDFDFDFDFDFD00ULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL
1528 },
1529 {
1530 0xFDFDFDFD00000000ULL,
1531 0xFDFDFDFDFD000000ULL,
1532 0xFDFDFDFDFDFD0000ULL,
1533 0xFDFDFDFDFDFDFD00ULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL
1538 },
1539 {
1540 0xFDFDFDFDFD000000ULL,
1541 0xFDFDFDFDFDFD0000ULL,
1542 0xFDFDFDFDFDFDFD00ULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL
1548 },
1549 {
1550 0xFDFDFDFDFDFD0000ULL,
1551 0xFDFDFDFDFDFDFD00ULL,
1552 0xFDFDFDFDFDFDFDFDULL,
1553 0xFDFDFDFDFDFDFDFDULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL
1558 },
1559 {
1560 0xFDFDFDFDFDFDFD00ULL,
1561 0xFDFDFDFDFDFDFDFDULL,
1562 0xFDFDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL
1568 },
1569 {
1570 0xFDFDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL
1578 }
1579 },
1580 {
1581 {
1582 0x0000000000000000ULL,
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL
1590 },
1591 {
1592 0x0000000000000000ULL,
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x00000000000000FDULL
1600 },
1601 {
1602 0x0000000000000000ULL,
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x00000000000000FDULL,
1609 0x000000000000FDFDULL
1610 },
1611 {
1612 0x0000000000000000ULL,
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x00000000000000FDULL,
1618 0x000000000000FDFDULL,
1619 0x0000000000FDFDFDULL
1620 },
1621 {
1622 0x0000000000000000ULL,
1623 0x0000000000000000ULL,
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x00000000000000FDULL,
1627 0x000000000000FDFDULL,
1628 0x0000000000FDFDFDULL,
1629 0x00000000FDFDFDFDULL
1630 },
1631 {
1632 0x0000000000000000ULL,
1633 0x0000000000000000ULL,
1634 0x0000000000000000ULL,
1635 0x00000000000000FDULL,
1636 0x000000000000FDFDULL,
1637 0x0000000000FDFDFDULL,
1638 0x00000000FDFDFDFDULL,
1639 0x000000FDFDFDFDFDULL
1640 },
1641 {
1642 0x0000000000000000ULL,
1643 0x0000000000000000ULL,
1644 0x00000000000000FDULL,
1645 0x000000000000FDFDULL,
1646 0x0000000000FDFDFDULL,
1647 0x00000000FDFDFDFDULL,
1648 0x000000FDFDFDFDFDULL,
1649 0x0000FDFDFDFDFDFDULL
1650 },
1651 {
1652 0x0000000000000000ULL,
1653 0x00000000000000FDULL,
1654 0x000000000000FDFDULL,
1655 0x0000000000FDFDFDULL,
1656 0x00000000FDFDFDFDULL,
1657 0x000000FDFDFDFDFDULL,
1658 0x0000FDFDFDFDFDFDULL,
1659 0x00FDFDFDFDFDFDFDULL
1660 },
1661 {
1662 0x00000000000000FDULL,
1663 0x000000000000FDFDULL,
1664 0x0000000000FDFDFDULL,
1665 0x00000000FDFDFDFDULL,
1666 0x000000FDFDFDFDFDULL,
1667 0x0000FDFDFDFDFDFDULL,
1668 0x00FDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL
1670 },
1671 {
1672 0x000000000000FDFDULL,
1673 0x0000000000FDFDFDULL,
1674 0x00000000FDFDFDFDULL,
1675 0x000000FDFDFDFDFDULL,
1676 0x0000FDFDFDFDFDFDULL,
1677 0x00FDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL
1680 },
1681 {
1682 0x0000000000FDFDFDULL,
1683 0x00000000FDFDFDFDULL,
1684 0x000000FDFDFDFDFDULL,
1685 0x0000FDFDFDFDFDFDULL,
1686 0x00FDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL
1690 },
1691 {
1692 0x00000000FDFDFDFDULL,
1693 0x000000FDFDFDFDFDULL,
1694 0x0000FDFDFDFDFDFDULL,
1695 0x00FDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL
1700 },
1701 {
1702 0x000000FDFDFDFDFDULL,
1703 0x0000FDFDFDFDFDFDULL,
1704 0x00FDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL
1710 },
1711 {
1712 0x0000FDFDFDFDFDFDULL,
1713 0x00FDFDFDFDFDFDFDULL,
1714 0xFDFDFDFDFDFDFDFDULL,
1715 0xFDFDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL
1720 },
1721 {
1722 0x00FDFDFDFDFDFDFDULL,
1723 0xFDFDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL
1730 },
1731 {
1732 0xFDFDFDFDFDFDFDFDULL,
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL
1740 }
1741 }
1742 };
1743
1744 int32_t black_opening_count=0;
1745 int32_t black_opening_x,black_opening_y;
1746 int32_t black_opening_shape;
1747
1748 1136 int32_t choose_opening_shape()
1749 {
1750 // First, count how many bits are set
1751 1136 int32_t numBits=0;
1752 int32_t bitCounter;
1753
1754
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 1136 times.
6816 for(int32_t i=0; i<bosMAX; i++)
1755 {
1756
2/2
✓ Branch 0 taken 4328 times.
✓ Branch 1 taken 1352 times.
5680 if(COOLSCROLL&(1<<i))
1757 1352 numBits++;
1758 5680 }
1759
1760 // Shouldn't happen...
1761
1/2
✓ Branch 0 taken 1136 times.
✗ Branch 1 not taken.
1136 if(numBits==0)
1762 return bosCIRCLE;
1763
1764 // Pick a bit
1765 1136 bitCounter=zc_rand()%numBits+1;
1766
1767
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 26 times.
1428 for(int32_t i=0; i<bosMAX; i++)
1768 {
1769 // If this bit is set, decrement the bit counter
1770
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1266 times.
1402 if(COOLSCROLL&(1<<i))
1771 1266 bitCounter--;
1772
1773 // When the counter hits 0, return a value based on
1774 // which bit it stopped on.
1775 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1776
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 292 times.
1402 if(bitCounter==0)
1777 1110 return i;
1778 292 }
1779
1780 // Shouldn't be necessary, but the compiler might complain, at least
1781 26 return bosCIRCLE;
1782 1136 }
1783
1784 311 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1785 {
1786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
311 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1787
1788 311 int32_t w=256, h=224;
1789 311 int32_t blockrows=28, blockcolumns=32;
1790 311 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1791
1792
2/2
✓ Branch 0 taken 8708 times.
✓ Branch 1 taken 311 times.
9019 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1793 {
1794
2/2
✓ Branch 0 taken 278656 times.
✓ Branch 1 taken 8708 times.
287364 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1795 {
1796
2/2
✓ Branch 0 taken 148380 times.
✓ Branch 1 taken 130276 times.
278656 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1797 278656 }
1798 8708 }
1799
1800 311 black_opening_count = 66;
1801 311 black_opening_x = x;
1802 311 black_opening_y = y;
1803 311 lensclk = 0;
1804 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1805
1806
1807
1/2
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
311 if(black_opening_shape == bosFADEBLACK)
1808 {
1809 refreshTints();
1810 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1811 }
1812
1/2
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
311 if(wait)
1813 {
1814 FFCore.warpScriptCheck();
1815 for(int32_t i=0; i<66; i++)
1816 {
1817 draw_screen(tmpscr);
1818 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1819 advanceframe(true);
1820
1821 if(Quit)
1822 {
1823 break;
1824 }
1825 }
1826 }
1827 311 }
1828
1829 825 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1830 {
1831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 825 times.
825 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1832
1833 825 int32_t w=256, h=224;
1834 825 int32_t blockrows=28, blockcolumns=32;
1835 825 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1836
1837
2/2
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 825 times.
23925 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1838 {
1839
2/2
✓ Branch 0 taken 739200 times.
✓ Branch 1 taken 23100 times.
762300 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1840 {
1841
2/2
✓ Branch 0 taken 335938 times.
✓ Branch 1 taken 403262 times.
739200 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1842 739200 }
1843 23100 }
1844
1845 825 black_opening_count = -66;
1846 825 black_opening_x = x;
1847 825 black_opening_y = y;
1848 825 lensclk = 0;
1849
1/2
✓ Branch 0 taken 825 times.
✗ Branch 1 not taken.
825 if(black_opening_shape == bosFADEBLACK)
1850 {
1851 refreshTints();
1852 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1853 }
1854
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 630 times.
825 if(wait)
1855 {
1856 630 FFCore.warpScriptCheck();
1857
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 41580 times.
42210 for(int32_t i=0; i<66; i++)
1858 {
1859 41580 draw_screen(tmpscr);
1860 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1861 41580 advanceframe(true);
1862
1863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41580 times.
41580 if(Quit)
1864 {
1865 break;
1866 }
1867 41580 }
1868 630 }
1869 825 }
1870
1871 74976 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1872 {
1873 74976 clear_to_color(tmp_scr,BLACK);
1874 74976 int32_t w=256, h=224;
1875
1876
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 2838 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70620 times.
74976 switch(black_opening_shape)
1877 {
1878 case bosOVAL:
1879 {
1880 858 double new_w=(w/2)+abs(w/2-x);
1881 858 double new_h=(h/2)+abs(h/2-y);
1882 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1883 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1884 858 break;
1885 }
1886
1887 case bosTRIANGLE:
1888 {
1889 660 double new_w=(w/2)+abs(w/2-x);
1890 660 double new_h=(h/2)+abs(h/2-y);
1891 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1892 660 double P2= (PI/2);
1893 660 double P23=(2*PI/3);
1894 660 double P43=(4*PI/3);
1895 660 double Pa= (-4*PI*a/(3*max_a));
1896 660 double angle=P2+Pa;
1897 660 double a0=angle;
1898 660 double a2=angle+P23;
1899 660 double a4=angle+P43;
1900 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1901 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1902 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1903 0);
1904 660 break;
1905 }
1906
1907 case bosSMAS:
1908 {
1909
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 1386 times.
2838 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1910
1911
2/2
✓ Branch 0 taken 79464 times.
✓ Branch 1 taken 2838 times.
82302 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1912 {
1913
2/2
✓ Branch 0 taken 635712 times.
✓ Branch 1 taken 79464 times.
715176 for(int32_t linerow=0; linerow<8; ++linerow)
1914 {
1915 635712 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1916
1917
2/2
✓ Branch 0 taken 20342784 times.
✓ Branch 1 taken 635712 times.
20978496 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1918 {
1919 61028352 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1920
6/6
✓ Branch 0 taken 14117840 times.
✓ Branch 1 taken 6224944 times.
✓ Branch 2 taken 13330568 times.
✓ Branch 3 taken 7012216 times.
✓ Branch 4 taken 7105624 times.
✓ Branch 5 taken 6224944 times.
20342784 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1921 20342784 [linerow];
1922 20342784 ++triangleline;
1923
1924
2/2
✓ Branch 0 taken 17799936 times.
✓ Branch 1 taken 2542848 times.
20342784 if(linerow==0)
1925 {
1926 2542848 }
1927 20342784 }
1928 635712 }
1929 79464 }
1930
1931 2838 break;
1932 }
1933
1934 case bosFADEBLACK:
1935 {
1936 if(black_opening_count<0)
1937 {
1938 black_fade(zc_min(-black_opening_count,63));
1939 }
1940 else if(black_opening_count>0)
1941 {
1942 black_fade(63-zc_max(black_opening_count-3,0));
1943 }
1944 else black_fade(0);
1945 return; //no blitting from tmp_scr!
1946 }
1947
1948 70620 case bosCIRCLE:
1949 default:
1950 {
1951 70620 double new_w=(w/2)+abs(w/2-x);
1952 70620 double new_h=(h/2)+abs(h/2-y);
1953 70620 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1954 //circlefill(tmp_scr,x,y,a<<3,0);
1955 70620 circlefill(tmp_scr,x,y,r,0);
1956 70620 break;
1957 }
1958 }
1959
1960 74976 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1961 74976 }
1962
1963
1964 void black_fade(int32_t fadeamnt)
1965 {
1966 for(int32_t i=0; i < 0xEF; i++)
1967 {
1968 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1969 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1970 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1971 }
1972
1973 refreshpal = true;
1974 }
1975
1976 //----------------------------------------------------------------
1977
1978 32851143 bool item_disabled(int32_t item) //is this item disabled?
1979 {
1980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32851143 times.
32851143 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1981 }
1982
1983 6703012 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1984 {
1985
2/2
✓ Branch 0 taken 80417 times.
✓ Branch 1 taken 6622595 times.
6703012 if(current_item(item_type, true) >=item)
1986 {
1987 80417 return true;
1988 }
1989
1990 6622595 return false;
1991 6703012 }
1992
1993 27649746 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1994 {
1995
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5065322 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3051917 times.
✓ Branch 6 taken 14694406 times.
✓ Branch 7 taken 4803363 times.
✓ Branch 8 taken 34738 times.
27649746 switch(item_type)
1996 {
1997 case itype_bomb:
1998 case itype_sbomb:
1999 {
2000 int32_t itemid = getItemID(itemsbuf, item_type, it);
2001
2002 if(itemid == -1)
2003 return false;
2004
2005 return (game->get_item(itemid));
2006 }
2007
2008 case itype_clock:
2009 {
2010 5065322 int32_t itemid = getItemID(itemsbuf, item_type, it);
2011
2012
2/4
✓ Branch 0 taken 5065322 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5065322 times.
✗ Branch 3 not taken.
5065322 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2013 return (game->get_item(itemid));
2014 5065322 return Hero.getClock()?1:0;
2015 }
2016
2017 case itype_key:
2018 return (game->get_keys()>0);
2019
2020 case itype_magiccontainer:
2021 return (game->get_maxmagic()>=game->get_mp_per_block());
2022
2023 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2024 {
2025
1/3
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3051917 switch(it)
2026 {
2027 case -2:
2028 {
2029 for(int32_t i=0; i<MAXLEVELS; i++)
2030 {
2031 if(game->lvlitems[i]&liTRIFORCE)
2032 {
2033 return true;
2034 }
2035 }
2036
2037 return false;
2038 }
2039
2040 case -1:
2041 return (game->lvlitems[dlevel]&liTRIFORCE);
2042
2043 default:
2044
2/4
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3051917 times.
3051917 if(it>=0&&it<MAXLEVELS)
2045 {
2046 3051917 return (game->lvlitems[it]&liTRIFORCE);
2047 }
2048
2049 break;
2050 }
2051
2052 return 0;
2053 }
2054
2055 case itype_map: //it: -2=any, -1=current level, other=that level
2056 {
2057
1/3
✓ Branch 0 taken 14694406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
14694406 switch(it)
2058 {
2059 case -2:
2060 {
2061 for(int32_t i=0; i<MAXLEVELS; i++)
2062 {
2063 if(game->lvlitems[i]&liMAP)
2064 {
2065 return true;
2066 }
2067 }
2068
2069 return false;
2070 }
2071
2072 case -1:
2073 return (game->lvlitems[dlevel]&liMAP)!=0;
2074
2075 default:
2076
2/4
✓ Branch 0 taken 14694406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14694406 times.
14694406 if(it>=0&&it<MAXLEVELS)
2077 {
2078 14694406 return (game->lvlitems[it]&liMAP)!=0;
2079 }
2080
2081 break;
2082 }
2083
2084 return 0;
2085 }
2086
2087 case itype_compass: //it: -2=any, -1=current level, other=that level
2088 {
2089
1/3
✓ Branch 0 taken 4803363 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4803363 switch(it)
2090 {
2091 case -2:
2092 {
2093 for(int32_t i=0; i<MAXLEVELS; i++)
2094 {
2095 if(game->lvlitems[i]&liCOMPASS)
2096 {
2097 return true;
2098 }
2099 }
2100
2101 return false;
2102 }
2103
2104 case -1:
2105 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2106
2107 default:
2108
2/4
✓ Branch 0 taken 4803363 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4803363 times.
✗ Branch 3 not taken.
4803363 if(it>=0&&it<MAXLEVELS)
2109 {
2110 4803363 return (game->lvlitems[it]&liCOMPASS)!=0;
2111 }
2112
2113 break;
2114 }
2115 return 0;
2116 }
2117
2118 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2119 {
2120
1/3
✓ Branch 0 taken 34738 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
34738 switch(it)
2121 {
2122 case -2:
2123 {
2124 for(int32_t i=0; i<MAXLEVELS; i++)
2125 {
2126 if(game->lvlitems[i]&liBOSSKEY)
2127 {
2128 return true;
2129 }
2130 }
2131
2132 return false;
2133 }
2134
2135 case -1:
2136 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2137
2138 default:
2139
2/4
✓ Branch 0 taken 34738 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34738 times.
34738 if(it>=0&&it<MAXLEVELS)
2140 {
2141 34738 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2142 }
2143 break;
2144 }
2145 return 0;
2146 }
2147
2148 default:
2149 //it=(1<<(it-1));
2150 /*if (item_type>=itype_max)
2151 {
2152 enter_sys_pal();
2153 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2154 exit_sys_pal();
2155
2156 return false;
2157 }*/
2158 int32_t itemid = getItemID(itemsbuf, item_type, it);
2159
2160 if(itemid == -1)
2161 return false;
2162
2163 return game->get_item(itemid);
2164 }
2165 27649746 }
2166
2167
2168 86414427 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2169 {
2170
9/9
✓ Branch 0 taken 5065322 times.
✓ Branch 1 taken 45891851 times.
✓ Branch 2 taken 5065322 times.
✓ Branch 3 taken 5065322 times.
✓ Branch 4 taken 5065322 times.
✓ Branch 5 taken 5065322 times.
✓ Branch 6 taken 5065322 times.
✓ Branch 7 taken 5065322 times.
✓ Branch 8 taken 5065322 times.
86414427 switch(item_type)
2171 {
2172 case itype_clock:
2173 {
2174 5065322 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2175
2176
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5065322 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5065322 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2177 return itemsbuf[maxid].fam_type;
2178
2179 5065322 return has_item(itype_clock,1) ? 1 : 0;
2180 }
2181
2182 case itype_key:
2183 5065322 return game->get_keys();
2184
2185 case itype_lkey:
2186 5065322 return game->lvlkeys[get_dlevel()];
2187
2188 case itype_magiccontainer:
2189 5065322 return game->get_maxmagic()/game->get_mp_per_block();
2190
2191 case itype_triforcepiece:
2192 {
2193 5065322 int32_t count=0;
2194
2195
2/2
✓ Branch 0 taken 2593444864 times.
✓ Branch 1 taken 5065322 times.
2598510186 for(int32_t i=0; i<MAXLEVELS; i++)
2196 {
2197 2593444864 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2198 2593444864 }
2199
2200 5065322 return count;
2201 }
2202
2203 case itype_map:
2204 {
2205 5065322 int32_t count=0;
2206
2207
2/2
✓ Branch 0 taken 2593444864 times.
✓ Branch 1 taken 5065322 times.
2598510186 for(int32_t i=0; i<MAXLEVELS; i++)
2208 {
2209 2593444864 count+=(game->lvlitems[i]&liMAP)?1:0;
2210 2593444864 }
2211
2212 5065322 return count;
2213 }
2214
2215 case itype_compass:
2216 {
2217 5065322 int32_t count=0;
2218
2219
2/2
✓ Branch 0 taken 2593444864 times.
✓ Branch 1 taken 5065322 times.
2598510186 for(int32_t i=0; i<MAXLEVELS; i++)
2220 {
2221 2593444864 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2222 2593444864 }
2223
2224 5065322 return count;
2225 }
2226
2227 case itype_bosskey:
2228 {
2229 5065322 int32_t count=0;
2230
2231
2/2
✓ Branch 0 taken 2593444864 times.
✓ Branch 1 taken 5065322 times.
2598510186 for(int32_t i=0; i<MAXLEVELS; i++)
2232 {
2233 2593444864 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2234 2593444864 }
2235
2236 5065322 return count;
2237 }
2238
2239 default:
2240 45891851 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2241
2242
2/2
✓ Branch 0 taken 8709356 times.
✓ Branch 1 taken 37182495 times.
45891851 if(maxid == -1)
2243 37182495 return 0;
2244
2245 8709356 return itemsbuf[maxid].fam_type;
2246 }
2247 86414427 }
2248
2249 79711415 int32_t current_item(int32_t item_type) //item currently being used
2250 {
2251 79711415 return current_item(item_type, true);
2252 }
2253
2254 39 std::map<int32_t, int32_t> itemcache;
2255
2256 // Not actually used by anything at the moment...
2257 void removeFromItemCache(int32_t itemclass)
2258 {
2259 itemcache.erase(itemclass);
2260 }
2261
2262 24307 void flushItemCache()
2263 {
2264 24307 itemcache.clear();
2265
2266 //also fix the active subscreen if items were deleted -DD
2267
1/2
✓ Branch 0 taken 24307 times.
✗ Branch 1 not taken.
24307 if(game != NULL)
2268 {
2269 24307 verifyBothWeapons();
2270 24307 load_Sitems(&QMisc);
2271 24307 }
2272 24307 }
2273
2274 // This is used often, so it should be as direct as possible.
2275 2823366292 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2276 {
2277
2/2
✓ Branch 0 taken 2764974535 times.
✓ Branch 1 taken 58391757 times.
2823366292 if(jinx_check)
2278 {
2279
4/4
✓ Branch 0 taken 38230555 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 34566891 times.
✓ Branch 3 taken 3663664 times.
58391757 if(!(HeroSwordClk() || HeroItemClk()))
2280 34566891 jinx_check = false; //not jinxed
2281 58391757 }
2282
4/4
✓ Branch 0 taken 2799244714 times.
✓ Branch 1 taken 24121578 times.
✓ Branch 2 taken 23650363 times.
✓ Branch 3 taken 2775594351 times.
2823366292 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2283 {
2284 2775594351 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2285
2286
2/2
✓ Branch 0 taken 2763184877 times.
✓ Branch 1 taken 12409474 times.
2775594351 if(res != itemcache.end())
2287 2763184877 return res->second;
2288 12409474 }
2289
2290 60181415 int32_t result = -1;
2291 60181415 int32_t highestlevel = -1;
2292
2293
2/2
✓ Branch 0 taken 15406442240 times.
✓ Branch 1 taken 60181415 times.
15466623655 for(int32_t i=0; i<MAXITEMS; i++)
2294 {
2295
5/6
✓ Branch 0 taken 1197692851 times.
✓ Branch 1 taken 14208749389 times.
✓ Branch 2 taken 17819187 times.
✓ Branch 3 taken 1179873664 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17819187 times.
15406442240 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2296 {
2297
4/4
✓ Branch 0 taken 5189652 times.
✓ Branch 1 taken 12629535 times.
✓ Branch 2 taken 1358199 times.
✓ Branch 3 taken 16460988 times.
17819187 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2298 {
2299 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2300
2/2
✓ Branch 0 taken 16460829 times.
✓ Branch 1 taken 159 times.
16460988 if(!checkmagiccost(i))
2301 {
2302
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 147 times.
159 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2303 12 }
2304 16460841 }
2305
6/6
✓ Branch 0 taken 15432454 times.
✓ Branch 1 taken 2386586 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2129898 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 759329 times.
17819040 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2306 {
2307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 759329 times.
759329 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2308 759329 continue;
2309 }
2310
2311
2/2
✓ Branch 0 taken 237659 times.
✓ Branch 1 taken 16822052 times.
17059711 if(itemsbuf[i].fam_type >= highestlevel)
2312 {
2313 16822052 highestlevel = itemsbuf[i].fam_type;
2314 16822052 result=i;
2315 16822052 }
2316 17059711 }
2317 15405682764 }
2318
2319
2/2
✓ Branch 0 taken 23824866 times.
✓ Branch 1 taken 36356549 times.
60181415 if(!jinx_check) //Can't cache jinx_check results
2320 36356549 itemcache[itemtype] = result;
2321 60181415 return result;
2322 2823366292 }
2323
2324 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2325 2799858872 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2326 {
2327 2799858872 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2328
2/2
✓ Branch 0 taken 34884337 times.
✓ Branch 1 taken 2764974535 times.
2799858872 if(!jinx_check) //If not already a jinx-immune-only check...
2329 {
2330 //And the player IS jinxed...
2331
4/4
✓ Branch 0 taken 2745078917 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3611802 times.
✓ Branch 3 taken 2741467115 times.
2764974535 if(HeroSwordClk() || HeroItemClk())
2332 {
2333 //Then do a jinx-immune-only check here
2334 23507420 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2335 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2336 //Should NOT need a compat rule, as this should always return -1 in old quests.
2337
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22404776 times.
23507420 if(ret2 > -1) return ret2;
2338 22404776 }
2339 2763871891 }
2340 2798756228 return ret;
2341 2799858872 }
2342 17627109 int32_t current_item_power(int32_t itemtype)
2343 {
2344 17627109 int32_t result = current_item_id(itemtype,true);
2345
2/2
✓ Branch 0 taken 13118389 times.
✓ Branch 1 taken 4508720 times.
17627109 return (result<0) ? 0 : itemsbuf[result].power;
2346 }
2347
2348 7 int32_t heart_container_id()
2349 {
2350
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2351 {
2352
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2353 {
2354 7 return i;
2355 }
2356 196 }
2357 return -1;
2358 7 }
2359
2360 5065322 int32_t item_tile_mod()
2361 {
2362 5065322 int32_t tile=0;
2363
2364
2/2
✓ Branch 0 taken 1054279 times.
✓ Branch 1 taken 4011043 times.
5065322 if(game->get_bombs())
2365 {
2366 4011043 int32_t itemid = current_item_id(itype_bomb,false);
2367
3/4
✓ Branch 0 taken 3929984 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3929984 times.
4011043 if(itemid > -1 && checkbunny(itemid))
2368 3929984 tile+=itemsbuf[itemid].ltm;
2369 4011043 }
2370
2371
2/2
✓ Branch 0 taken 3894888 times.
✓ Branch 1 taken 1170434 times.
5065322 if(game->get_sbombs())
2372 {
2373 1170434 int32_t itemid = current_item_id(itype_sbomb,false);
2374
3/4
✓ Branch 0 taken 1169006 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1169006 times.
1170434 if(itemid > -1 && checkbunny(itemid))
2375 1169006 tile+=itemsbuf[itemid].ltm;
2376 1170434 }
2377
2378
2/2
✓ Branch 0 taken 4960318 times.
✓ Branch 1 taken 105004 times.
5065322 if(current_item(itype_clock))
2379 {
2380 105004 int32_t itemid =
2381
1/2
✓ Branch 0 taken 105004 times.
✗ Branch 1 not taken.
105004 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2382 ? iClock
2383 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2384
2/4
✓ Branch 0 taken 105004 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105004 times.
105004 if(itemid > -1 && checkbunny(itemid))
2385 105004 tile+=itemsbuf[itemid].ltm;
2386 105004 }
2387
2388
2/2
✓ Branch 0 taken 4019410 times.
✓ Branch 1 taken 1045912 times.
5065322 if(current_item(itype_key))
2389 {
2390 1045912 int32_t itemid =
2391
1/2
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
1045912 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2392 ? iKey
2393 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2394
2/4
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1045912 times.
1045912 if(itemid > -1 && checkbunny(itemid))
2395 1045912 tile+=itemsbuf[itemid].ltm;
2396 1045912 }
2397
2398
2/2
✓ Branch 0 taken 4892791 times.
✓ Branch 1 taken 172531 times.
5065322 if(current_item(itype_lkey))
2399 {
2400 172531 int32_t itemid =
2401
2/2
✓ Branch 0 taken 171621 times.
✓ Branch 1 taken 910 times.
172531 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2402 ? iLevelKey
2403 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2404
2/4
✓ Branch 0 taken 172531 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 172531 times.
172531 if(itemid > -1 && checkbunny(itemid))
2405 172531 tile+=itemsbuf[itemid].ltm;
2406 172531 }
2407
2408
2/2
✓ Branch 0 taken 1029846 times.
✓ Branch 1 taken 4035476 times.
5065322 if(current_item(itype_map))
2409 {
2410 4035476 int32_t itemid =
2411
2/2
✓ Branch 0 taken 4034690 times.
✓ Branch 1 taken 786 times.
4035476 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2412 ? iMap
2413 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2414
2/4
✓ Branch 0 taken 4035476 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4035476 times.
4035476 if(itemid > -1 && checkbunny(itemid))
2415 4035476 tile+=itemsbuf[itemid].ltm;
2416 4035476 }
2417
2418
2/2
✓ Branch 0 taken 1007964 times.
✓ Branch 1 taken 4057358 times.
5065322 if(current_item(itype_compass))
2419 {
2420 4057358 int32_t itemid =
2421
2/2
✓ Branch 0 taken 3976299 times.
✓ Branch 1 taken 81059 times.
4057358 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2422 ? iCompass
2423 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2424
2/4
✓ Branch 0 taken 4057358 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4057358 times.
4057358 if(itemid > -1 && checkbunny(itemid))
2425 4057358 tile+=itemsbuf[itemid].ltm;
2426 4057358 }
2427
2428
2/2
✓ Branch 0 taken 3196118 times.
✓ Branch 1 taken 1869204 times.
5065322 if(current_item(itype_bosskey))
2429 {
2430 1869204 int32_t itemid =
2431
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2432 ? iBossKey
2433 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2434
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2435 1869204 tile+=itemsbuf[itemid].ltm;
2436 1869204 }
2437
2438
2/2
✓ Branch 0 taken 2909073 times.
✓ Branch 1 taken 2156249 times.
5065322 if(current_item(itype_magiccontainer))
2439 {
2440 2156249 int32_t itemid =
2441
2/2
✓ Branch 0 taken 2063262 times.
✓ Branch 1 taken 92987 times.
2156249 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2442 ? iMagicC
2443 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2444
3/4
✓ Branch 0 taken 2156249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2154379 times.
2156249 if(itemid > -1 && checkbunny(itemid))
2445 2154379 tile+=itemsbuf[itemid].ltm;
2446 2156249 }
2447
2448
2/2
✓ Branch 0 taken 1366029 times.
✓ Branch 1 taken 3699293 times.
5065322 if(current_item(itype_triforcepiece))
2449 {
2450 3699293 int32_t itemid =
2451
1/2
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
3699293 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2452 ? iTriforce
2453 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2454
2/4
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3699293 times.
3699293 if(itemid > -1 && checkbunny(itemid))
2455 3699293 tile+=itemsbuf[itemid].ltm;
2456 3699293 }
2457
2458
2/2
✓ Branch 0 taken 5065322 times.
✓ Branch 1 taken 2593444864 times.
2598510186 for(int32_t i=0; i<itype_max; i++)
2459 {
2460
2/2
✓ Branch 0 taken 2541357056 times.
✓ Branch 1 taken 52087808 times.
2593444864 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2461 {
2462
2/2
✓ Branch 0 taken 1017340 times.
✓ Branch 1 taken 51070468 times.
52087808 switch(i)
2463 {
2464 case itype_bomb:
2465 case itype_sbomb:
2466 case itype_clock:
2467 case itype_key:
2468 case itype_lkey:
2469 case itype_map:
2470 case itype_compass:
2471 case itype_bosskey:
2472 case itype_magiccontainer:
2473 case itype_triforcepiece:
2474 1017340 continue; //already handled
2475 }
2476 51070468 }
2477 2592427524 int32_t itemid = current_item_id(i,false);
2478
2/2
✓ Branch 0 taken 2587362202 times.
✓ Branch 1 taken 5065322 times.
2592427524 if(i == itype_shield)
2479 5065322 itemid = getCurrentShield(false);
2480
2481
4/4
✓ Branch 0 taken 70903837 times.
✓ Branch 1 taken 2521523687 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 70802856 times.
2592427524 if(itemid < 0 || !checkbunny(itemid))
2482 2521624668 continue;
2483
2484 70802856 itemdata const& itm = itemsbuf[itemid];
2485
2486
2/2
✓ Branch 0 taken 66352341 times.
✓ Branch 1 taken 4450515 times.
70802856 switch(itm.family)
2487 {
2488 case itype_shield:
2489
1/2
✓ Branch 0 taken 4450515 times.
✗ Branch 1 not taken.
4450515 if(itm.flags & ITEM_FLAG9) //active shield
2490 {
2491 if(!usingActiveShield(itemid))
2492 {
2493 tile+=itm.misc6; //'Inactive PTM'
2494 continue;
2495 }
2496 }
2497 4450515 break;
2498 }
2499
2500 70802856 tile+=itm.ltm;
2501 70802856 }
2502
2503 5065322 return tile;
2504 }
2505
2506 5065322 int32_t bunny_tile_mod()
2507 {
2508
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 5063452 times.
5065322 if(Hero.BunnyClock())
2509 {
2510 1870 return game->get_bunny_ltm();
2511 }
2512 5063452 return 0;
2513 5065322 }
2514
2515 // Hints are drawn on a separate layer to combo reveals.
2516 16332 void draw_lens_under(BITMAP *dest, bool layer)
2517 {
2518 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2519 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2520 //Lens flag 3: Don't show armos/chest/dive items
2521 //Lens flag 4: Show Raft Paths
2522 //Lens flag 5: Show Invisible Enemies
2523
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2524
2525 16332 int32_t strike_hint_table[11]=
2526 {
2527 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2528 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2529 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2530 };
2531
2532 // int32_t page = tmpscr->cpage;
2533 {
2534 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2535 // int32_t temptimer=0;
2536 16332 int32_t tempitem, tempweapon=0;
2537 16332 strike_hint=strike_hint_table[strike_hint_counter];
2538
2539
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2540 {
2541 492 strike_hint_timer=0;
2542 492 strike_hint_counter=((strike_hint_counter+1)%11);
2543 492 }
2544
2545 16332 ++strike_hint_timer;
2546
2547
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2548 {
2549 2874432 int32_t x = (i & 15) << 4;
2550 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2551 2874432 int32_t tempitemx=-16, tempitemy=-16;
2552 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2553
2554
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2555 {
2556 5748864 int32_t checkflag=0;
2557
2558
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2559 {
2560 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2561 2874432 }
2562 else
2563 {
2564 2874432 checkflag=tmpscr->sflag[i];
2565 }
2566
2567
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2568 {
2569
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2570 {
2571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2572 906 }
2573 else
2574 {
2575 192 checkflag = strike_hint;
2576 }
2577 1098 }
2578
2579
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2580 {
2581 case 0:
2582 case mfZELDA:
2583 case mfPUSHED:
2584 case mfENEMY0:
2585 case mfENEMY1:
2586 case mfENEMY2:
2587 case mfENEMY3:
2588 case mfENEMY4:
2589 case mfENEMY5:
2590 case mfENEMY6:
2591 case mfENEMY7:
2592 case mfENEMY8:
2593 case mfENEMY9:
2594 case mfSINGLE:
2595 case mfSINGLE16:
2596 case mfNOENEMY:
2597 case mfTRAP_H:
2598 case mfTRAP_V:
2599 case mfTRAP_4:
2600 case mfTRAP_LR:
2601 case mfTRAP_UD:
2602 case mfNOGROUNDENEMY:
2603 case mfNOBLOCKS:
2604 case mfSCRIPT1:
2605 case mfSCRIPT2:
2606 case mfSCRIPT3:
2607 case mfSCRIPT4:
2608 case mfSCRIPT5:
2609 case mfSCRIPT6:
2610 case mfSCRIPT7:
2611 case mfSCRIPT8:
2612 case mfSCRIPT9:
2613 case mfSCRIPT10:
2614 case mfSCRIPT11:
2615 case mfSCRIPT12:
2616 case mfSCRIPT13:
2617 case mfSCRIPT14:
2618 case mfSCRIPT15:
2619 case mfSCRIPT16:
2620 case mfSCRIPT17:
2621 case mfSCRIPT18:
2622 case mfSCRIPT19:
2623 case mfSCRIPT20:
2624 case mfPITHOLE:
2625 case mfPITFALLFLOOR:
2626 case mfLAVA:
2627 case mfICE:
2628 case mfICEDAMAGE:
2629 case mfDAMAGE1:
2630 case mfDAMAGE2:
2631 case mfDAMAGE4:
2632 case mfDAMAGE8:
2633 case mfDAMAGE16:
2634 case mfDAMAGE32:
2635 case mfFREEZEALL:
2636 case mfFREZEALLANSFFCS:
2637 case mfFREEZEFFCSOLY:
2638 case mfSCRITPTW1TRIG:
2639 case mfSCRITPTW2TRIG:
2640 case mfSCRITPTW3TRIG:
2641 case mfSCRITPTW4TRIG:
2642 case mfSCRITPTW5TRIG:
2643 case mfSCRITPTW6TRIG:
2644 case mfSCRITPTW7TRIG:
2645 case mfSCRITPTW8TRIG:
2646 case mfSCRITPTW9TRIG:
2647 case mfSCRITPTW10TRIG:
2648 case mfTROWEL:
2649 case mfTROWELNEXT:
2650 case mfTROWELSPECIALITEM:
2651 case mfSLASHPOT:
2652 case mfLIFTPOT:
2653 case mfLIFTORSLASH:
2654 case mfLIFTROCK:
2655 case mfLIFTROCKHEAVY:
2656 case mfDROPITEM:
2657 case mfSPECIALITEM:
2658 case mfDROPKEY:
2659 case mfDROPLKEY:
2660 case mfDROPCOMPASS:
2661 case mfDROPMAP:
2662 case mfDROPBOSSKEY:
2663 case mfSPAWNNPC:
2664 case mfSWITCHHOOK:
2665 case mfSIDEVIEWLADDER:
2666 case mfSIDEVIEWPLATFORM:
2667 case mfNOENEMYSPAWN:
2668 case mfENEMYALL:
2669 case mfNOMIRROR:
2670 case mfUNSAFEGROUND:
2671 case mf168:
2672 case mf169:
2673 case mf170:
2674 case mf171:
2675 case mf172:
2676 case mf173:
2677 case mf174:
2678 case mf175:
2679 case mf176:
2680 case mf177:
2681 case mf178:
2682 case mf179:
2683 case mf180:
2684 case mf181:
2685 case mf182:
2686 case mf183:
2687 case mf184:
2688 case mf185:
2689 case mf186:
2690 case mf187:
2691 case mf188:
2692 case mf189:
2693 case mf190:
2694 case mf191:
2695 case mf192:
2696 case mf193:
2697 case mf194:
2698 case mf195:
2699 case mf196:
2700 case mf197:
2701 case mf198:
2702 case mf199:
2703 case mf200:
2704 case mf201:
2705 case mf202:
2706 case mf203:
2707 case mf204:
2708 case mf205:
2709 case mf206:
2710 case mf207:
2711 case mf208:
2712 case mf209:
2713 case mf210:
2714 case mf211:
2715 case mf212:
2716 case mf213:
2717 case mf214:
2718 case mf215:
2719 case mf216:
2720 case mf217:
2721 case mf218:
2722 case mf219:
2723 case mf220:
2724 case mf221:
2725 case mf222:
2726 case mf223:
2727 case mf224:
2728 case mf225:
2729 case mf226:
2730 case mf227:
2731 case mf228:
2732 case mf229:
2733 case mf230:
2734 case mf231:
2735 case mf232:
2736 case mf233:
2737 case mf234:
2738 case mf235:
2739 case mf236:
2740 case mf237:
2741 case mf238:
2742 case mf239:
2743 case mf240:
2744 case mf241:
2745 case mf242:
2746 case mf243:
2747 case mf244:
2748 case mf245:
2749 case mf246:
2750 case mf247:
2751 case mf248:
2752 case mf249:
2753 case mf250:
2754 case mf251:
2755 case mf252:
2756 case mf253:
2757 case mf254:
2758 case mfEXTENDED:
2759 5706470 break;
2760
2761 case mfPUSHUD:
2762 case mfPUSHLR:
2763 case mfPUSH4:
2764 case mfPUSHU:
2765 case mfPUSHD:
2766 case mfPUSHL:
2767 case mfPUSHR:
2768 case mfPUSHUDNS:
2769 case mfPUSHLRNS:
2770 case mfPUSH4NS:
2771 case mfPUSHUNS:
2772 case mfPUSHDNS:
2773 case mfPUSHLNS:
2774 case mfPUSHRNS:
2775 case mfPUSHUDINS:
2776 case mfPUSHLRINS:
2777 case mfPUSH4INS:
2778 case mfPUSHUINS:
2779 case mfPUSHDINS:
2780 case mfPUSHLINS:
2781 case mfPUSHRINS:
2782
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2783
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2784 {
2785 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2786 }
2787
2788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2789
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2790 {
2791
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2792 {
2793
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2794 {
2795 case cPUSH_HEAVY:
2796 case cPUSH_HW:
2797 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2798 72 tempitemx=x, tempitemy=y;
2799
2800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2801 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2802
2803 72 break;
2804
2805 case cPUSH_HEAVY2:
2806 case cPUSH_HW2:
2807 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2808 63 tempitemx=x, tempitemy=y;
2809
2810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2811 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2812
2813 63 break;
2814 }
2815 1032 }
2816 2438 }
2817
2818 3148 break;
2819
2820 case mfWHISTLE:
2821
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2822 {
2823 tempitem=getItemID(itemsbuf,itype_whistle,1);
2824
2825 if(tempitem<0) break;
2826
2827 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2828 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2829 {
2830 tempitemx=x;
2831 tempitemy=y;
2832 }
2833
2834 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2835 }
2836
2837 2418 break;
2838
2839 //Why is this here?
2840 case mfFAIRY:
2841 case mfMAGICFAIRY:
2842 case mfALLFAIRY:
2843 if(hints)
2844 {
2845 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2846
2847 if(tempitem < 0) break;
2848
2849 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2850 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2851 {
2852 tempitemx=x;
2853 tempitemy=y;
2854 }
2855
2856 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2857 }
2858
2859 break;
2860
2861 case mfANYFIRE:
2862
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2863 {
2864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2865 252 }
2866 else
2867 {
2868 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2869
2870
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2871
2872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2873
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2874 {
2875 189 tempitemx=x;
2876 189 tempitemy=y;
2877 189 }
2878
2879 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2880 }
2881
2882 504 break;
2883
2884 case mfSTRONGFIRE:
2885 if(!hints)
2886 {
2887 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2888 }
2889 else
2890 {
2891 tempitem=getItemID(itemsbuf,itype_candle,2);
2892
2893 if(tempitem<0) break;
2894
2895 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2896 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2897 {
2898 tempitemx=x;
2899 tempitemy=y;
2900 }
2901
2902 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2903 }
2904
2905 break;
2906
2907 case mfMAGICFIRE:
2908 if(!hints)
2909 {
2910 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2911 }
2912 else
2913 {
2914 tempitem=getItemID(itemsbuf,itype_wand,1);
2915
2916 if(tempitem<0) break;
2917
2918 tempweapon=wFire;
2919
2920 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2921 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2922 {
2923 tempitemx=x;
2924 tempitemy=y;
2925 }
2926 else
2927 {
2928 tempweaponx=x;
2929 tempweapony=y;
2930 }
2931
2932 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2933 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2934 }
2935
2936 break;
2937
2938 case mfDIVINEFIRE:
2939 if(!hints)
2940 {
2941 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2942 }
2943 else
2944 {
2945 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2946
2947 if(tempitem<0) break;
2948
2949 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2950 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2951 {
2952 tempitemx=x;
2953 tempitemy=y;
2954 }
2955
2956 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2957 }
2958
2959 break;
2960
2961 case mfARROW:
2962
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2963 {
2964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2965 732 }
2966 else
2967 {
2968 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2969
2970
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2971
2972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2973
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2974 {
2975 61 tempitemx=x;
2976 61 tempitemy=y;
2977 61 }
2978
2979 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2980 }
2981
2982 814 break;
2983
2984 case mfSARROW:
2985 if(!hints)
2986 {
2987 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2988 }
2989 else
2990 {
2991 tempitem=getItemID(itemsbuf,itype_arrow,2);
2992
2993 if(tempitem<0) break;
2994
2995 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2996 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2997 {
2998 tempitemx=x;
2999 tempitemy=y;
3000 }
3001
3002 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3003 }
3004
3005 break;
3006
3007 case mfGARROW:
3008 if(!hints)
3009 {
3010 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3011 }
3012 else
3013 {
3014 tempitem=getItemID(itemsbuf,itype_arrow,3);
3015
3016 if(tempitem<0) break;
3017
3018 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3019 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3020 {
3021 tempitemx=x;
3022 tempitemy=y;
3023 }
3024
3025 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3026 }
3027
3028 break;
3029
3030 case mfBOMB:
3031
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3032 {
3033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3034 16 }
3035 else
3036 {
3037 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3038 17 tempweapon = wLitBomb;
3039
3040 //if (tempitem<0) break;
3041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3042
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3043 {
3044 12 tempweaponx=x;
3045 12 tempweapony=y;
3046 12 }
3047
3048 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3049 }
3050
3051 33 break;
3052
3053 case mfSBOMB:
3054
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3055 {
3056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3057 48 }
3058 else
3059 {
3060 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3061 //if (tempitem<0) break;
3062 48 tempweapon = wLitSBomb;
3063
3064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3065
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3066 {
3067 36 tempweaponx=x;
3068 36 tempweapony=y;
3069 36 }
3070
3071 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3072 }
3073
3074 96 break;
3075
3076 case mfARMOS_SECRET:
3077
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3078 {
3079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3080 12 }
3081 24 break;
3082
3083 case mfBRANG:
3084
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3085 {
3086 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3087 }
3088 else
3089 {
3090 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3091
3092
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3093
3094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3095
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3096 {
3097 4 tempitemx=x;
3098 4 tempitemy=y;
3099 4 }
3100
3101 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3102 }
3103
3104 5 break;
3105
3106 case mfMBRANG:
3107 if(!hints)
3108 {
3109 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3110 }
3111 else
3112 {
3113 tempitem=getItemID(itemsbuf,itype_brang,2);
3114
3115 if(tempitem<0) break;
3116
3117 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3118 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3119 {
3120 tempitemx=x;
3121 tempitemy=y;
3122 }
3123
3124 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3125 }
3126
3127 break;
3128
3129 case mfFBRANG:
3130 if(!hints)
3131 {
3132 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3133 }
3134 else
3135 {
3136 tempitem=getItemID(itemsbuf,itype_brang,3);
3137
3138 if(tempitem<0) break;
3139
3140 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3141 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3142 {
3143 tempitemx=x;
3144 tempitemy=y;
3145 }
3146
3147 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3148 }
3149
3150 break;
3151
3152 case mfWANDMAGIC:
3153 if(!hints)
3154 {
3155 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3156 }
3157 else
3158 {
3159 tempitem=getItemID(itemsbuf,itype_wand,1);
3160
3161 if(tempitem<0) break;
3162
3163 tempweapon=itemsbuf[tempitem].wpn3;
3164
3165 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3166 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3167 {
3168 tempitemx=x;
3169 tempitemy=y;
3170 }
3171 else
3172 {
3173 tempweaponx=x;
3174 tempweapony=y;
3175 --lens_hint_weapon[wMagic][4];
3176
3177 if(lens_hint_weapon[wMagic][4]<-8)
3178 {
3179 lens_hint_weapon[wMagic][4]=8;
3180 }
3181 }
3182
3183 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3184 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3185 }
3186
3187 break;
3188
3189 case mfREFMAGIC:
3190
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3191 {
3192 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3193 }
3194 else
3195 {
3196 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3197
3198
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3199
3200 16 tempweapon=ewMagic;
3201
3202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3203
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3204 {
3205 13 tempitemx=x;
3206 13 tempitemy=y;
3207 13 }
3208 else
3209 {
3210 3 tempweaponx=x;
3211 3 tempweapony=y;
3212
3213
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3214 {
3215 1 --lens_hint_weapon[ewMagic][4];
3216 1 }
3217 else
3218 {
3219 2 ++lens_hint_weapon[ewMagic][4];
3220 }
3221
3222
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3223 {
3224 lens_hint_weapon[ewMagic][2]=up;
3225 }
3226
3227
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3228 {
3229 2 lens_hint_weapon[ewMagic][2]=down;
3230 2 }
3231 }
3232
3233 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3234 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3235 }
3236
3237 16 break;
3238
3239 case mfREFFIREBALL:
3240
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3241 {
3242 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3243 }
3244 else
3245 {
3246 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3247
3248
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3249
3250 16 tempweapon=ewFireball;
3251
3252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3253
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3254 {
3255 12 tempitemx=x;
3256 12 tempitemy=y;
3257 12 tempweaponx=x;
3258 12 tempweapony=y;
3259 12 ++lens_hint_weapon[ewFireball][3];
3260
3261
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3262 {
3263 1 lens_hint_weapon[ewFireball][3]=-8;
3264 1 lens_hint_weapon[ewFireball][4]=8;
3265 1 }
3266
3267
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3268 {
3269 8 ++lens_hint_weapon[ewFireball][4];
3270 8 }
3271 else
3272 {
3273 4 --lens_hint_weapon[ewFireball][4];
3274 }
3275 12 }
3276
3277 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3278 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3279 }
3280
3281 16 break;
3282
3283 case mfSWORD:
3284
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3285 {
3286 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3287 }
3288 else
3289 {
3290 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3291
3292
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3293
3294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3295
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3296 {
3297 5 tempitemx=x;
3298 5 tempitemy=y;
3299 5 }
3300
3301 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3302 }
3303
3304 7 break;
3305
3306 case mfWSWORD:
3307 if(!hints)
3308 {
3309 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3310 }
3311 else
3312 {
3313 tempitem=getItemID(itemsbuf,itype_sword,2);
3314
3315 if(tempitem<0) break;
3316
3317 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3318 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3319 {
3320 tempitemx=x;
3321 tempitemy=y;
3322 }
3323
3324 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3325 }
3326
3327 break;
3328
3329 case mfMSWORD:
3330 if(!hints)
3331 {
3332 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3333 }
3334 else
3335 {
3336 tempitem=getItemID(itemsbuf,itype_sword,3);
3337
3338 if(tempitem<0) break;
3339
3340 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3341 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3342 {
3343 tempitemx=x;
3344 tempitemy=y;
3345 }
3346
3347 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3348 }
3349
3350 break;
3351
3352 case mfXSWORD:
3353 if(!hints)
3354 {
3355 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3356 }
3357 else
3358 {
3359 tempitem=getItemID(itemsbuf,itype_sword,4);
3360
3361 if(tempitem<0) break;
3362
3363 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3364 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3365 {
3366 tempitemx=x;
3367 tempitemy=y;
3368 }
3369
3370 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3371 }
3372
3373 break;
3374
3375 case mfSWORDBEAM:
3376
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3377 {
3378 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3379 }
3380 else
3381 {
3382 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3383
3384
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3385
3386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3387
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3388 {
3389 11 tempitemx=x;
3390 11 tempitemy=y;
3391 11 }
3392
3393 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3394 }
3395
3396 16 break;
3397
3398 case mfWSWORDBEAM:
3399 if(!hints)
3400 {
3401 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3402 }
3403 else
3404 {
3405 tempitem=getItemID(itemsbuf,itype_sword,2);
3406
3407 if(tempitem<0) break;
3408
3409 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3410 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3411 {
3412 tempitemx=x;
3413 tempitemy=y;
3414 }
3415
3416 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3417 }
3418
3419 break;
3420
3421 case mfMSWORDBEAM:
3422 if(!hints)
3423 {
3424 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3425 }
3426 else
3427 {
3428 tempitem=getItemID(itemsbuf,itype_sword,3);
3429
3430 if(tempitem<0) break;
3431
3432 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3433 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3434 {
3435 tempitemx=x;
3436 tempitemy=y;
3437 }
3438
3439 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3440 }
3441
3442 break;
3443
3444 case mfXSWORDBEAM:
3445 if(!hints)
3446 {
3447 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3448 }
3449 else
3450 {
3451 tempitem=getItemID(itemsbuf,itype_sword,4);
3452
3453 if(tempitem<0) break;
3454
3455 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3456 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3457 {
3458 tempitemx=x;
3459 tempitemy=y;
3460 }
3461
3462 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3463 }
3464
3465 break;
3466
3467 case mfHOOKSHOT:
3468
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3469 {
3470 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3471 }
3472 else
3473 {
3474 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3475
3476
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3477
3478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3479
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3480 {
3481 12 tempitemx=x;
3482 12 tempitemy=y;
3483 12 }
3484
3485 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3486 }
3487
3488 17 break;
3489
3490 case mfWAND:
3491
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3492 {
3493 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3494 }
3495 else
3496 {
3497 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3498
3499
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3500
3501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3502
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3503 {
3504 28 tempitemx=x;
3505 28 tempitemy=y;
3506 28 }
3507
3508 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3509 }
3510
3511 35 break;
3512
3513 case mfHAMMER:
3514
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3515 {
3516 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3517 }
3518 else
3519 {
3520 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3521
3522
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3523
3524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3525
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3526 {
3527 13 tempitemx=x;
3528 13 tempitemy=y;
3529 13 }
3530
3531 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3532 }
3533
3534 17 break;
3535
3536 case mfARMOS_ITEM:
3537 case mfDIVE_ITEM:
3538
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3539 {
3540 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3541 2064 }
3542 2064 break;
3543
3544 case 16:
3545 case 17:
3546 case 18:
3547 case 19:
3548 case 20:
3549 case 21:
3550 case 22:
3551 case 23:
3552 case 24:
3553 case 25:
3554 case 26:
3555 case 27:
3556 case 28:
3557 case 29:
3558 case 30:
3559 case 31:
3560
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3562 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3563
3564 3618 break;
3565 case mfSECRETSNEXT:
3566 if(!hints)
3567 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3568 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3569
3570 break;
3571
3572 case mfSTRIKE:
3573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3574 {
3575 906 goto special;
3576 }
3577 else
3578 {
3579 break;
3580 }
3581
3582 28640 default: goto special;
3583
3584 special:
3585
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3586 {
3587
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3588 {
3589 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3590 4913 }
3591 6549 }
3592
3593 29546 break;
3594 }
3595 5748864 }
3596 2874432 }
3597
3598
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3599 {
3600
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3601 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3602
3603
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3604 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3605
3606
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3607 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3608
3609
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3610 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3611
3612
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3613 {
3614 43 showbombeddoor(dest, 0);
3615 43 }
3616
3617
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3618 {
3619 39 showbombeddoor(dest, 1);
3620 39 }
3621
3622
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3623 {
3624 showbombeddoor(dest, 2);
3625 }
3626
3627
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3628 {
3629 37 showbombeddoor(dest, 3);
3630 37 }
3631 8166 }
3632
3633
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3634 {
3635
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3636 {
3637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3638 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3639 1123 }
3640 else
3641 {
3642
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3643 {
3644 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3645 48 int32_t tempitemx=-16;
3646 48 int32_t tempitemy=-16;
3647
3648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3649
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3650 {
3651 24 tempitemx=tmpscr->stairx;
3652 24 tempitemy=tmpscr->stairy+playing_field_offset;
3653 24 }
3654
3655 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3656 48 }
3657 }
3658 2034 }
3659 }
3660 16332 }
3661
3662 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3663
3664 7997 void draw_lens_over()
3665 {
3666 // Oh, what the heck.
3667 static BITMAP *lens_scr = NULL;
3668 static int32_t last_width = -1;
3669 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3670
3671 // Only redraw the circle if the size has changed
3672
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3673 {
3674
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3675 {
3676 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3677 5 }
3678
3679 5 clear_to_color(lens_scr, BLACK);
3680 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3681 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3682 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3683 5 last_width=width;
3684 5 }
3685
3686 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3687 7997 }
3688
3689 //----------------------------------------------------------------
3690
3691 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3692 {
3693 //recreating a big bitmap every frame is highly sluggish.
3694
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3695 30701 clear_to_color(wavebuf, BLACK);
3696 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3697
3698 int32_t ofs;
3699 // int32_t amplitude=8;
3700 // int32_t wavelength=4;
3701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3702
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3703 30701 int32_t amp2=168;
3704
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3705 30701 int32_t i=frame%amp2;
3706
3707
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3708 {
3709
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3710 {
3711 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3712 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3713 }
3714 else
3715 {
3716 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3717 }
3718
3719
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3720 {
3721
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3722 {
3723 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3724 1320388608 }
3725 5157768 }
3726 5157768 }
3727 30701 }
3728
3729 3360 void draw_fuzzy(int32_t fuzz)
3730 // draws from right half of scrollbuf to framebuf
3731 {
3732 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3733 byte *start, *si, *di;
3734
3735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if(fuzz<1)
3736 fuzz = 1;
3737
3738 3360 xstep = 128%fuzz;
3739
3740
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 2660 times.
3360 if(xstep > 0)
3741 2660 xstep = fuzz-xstep;
3742
3743 3360 ystep = 112%fuzz;
3744
3745
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 2380 times.
3360 if(ystep > 0)
3746 2380 ystep = fuzz-ystep;
3747
3748 3360 firsty = 1;
3749
3750
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 121240 times.
124600 for(y=0; y<224;)
3751 {
3752 121240 start = &(scrollbuf->line[y][256]);
3753
3754
4/4
✓ Branch 0 taken 119560 times.
✓ Branch 1 taken 754320 times.
✓ Branch 2 taken 752640 times.
✓ Branch 3 taken 121240 times.
873880 for(dy=0; dy<ystep && dy+y<224; dy++)
3755 {
3756 752640 si = start;
3757 752640 di = &(framebuf->line[y+dy][0]);
3758 752640 i = xstep;
3759 752640 firstx = 1;
3760
3761
2/2
✓ Branch 0 taken 192675840 times.
✓ Branch 1 taken 752640 times.
193428480 for(dx=0; dx<256; dx++)
3762 {
3763 192675840 *(di++) = *si;
3764
3765
2/2
✓ Branch 0 taken 162350720 times.
✓ Branch 1 taken 30325120 times.
192675840 if(++i >= fuzz)
3766 {
3767
2/2
✓ Branch 0 taken 29572480 times.
✓ Branch 1 taken 752640 times.
30325120 if(!firstx)
3768 29572480 si += fuzz;
3769 else
3770 {
3771 752640 si += fuzz-xstep;
3772 752640 firstx = 0;
3773 }
3774
3775 30325120 i = 0;
3776 30325120 }
3777 192675840 }
3778 752640 }
3779
3780
2/2
✓ Branch 0 taken 117880 times.
✓ Branch 1 taken 3360 times.
121240 if(!firsty)
3781 117880 y += fuzz;
3782 else
3783 {
3784 3360 y += ystep;
3785 3360 ystep = fuzz;
3786 3360 firsty = 0;
3787 }
3788 }
3789 3360 }
3790
3791 8116902 void updatescr(bool allowwavy)
3792 {
3793
4/6
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 8116863 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
8116902 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3794
4/6
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 8116863 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
8116902 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3795
3796
2/2
✓ Branch 0 taken 8090137 times.
✓ Branch 1 taken 26765 times.
8116902 if(toogam)
3797 {
3798 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3799 26765 }
3800
3801
1/2
✓ Branch 0 taken 8116902 times.
✗ Branch 1 not taken.
8116902 if(Showpal)
3802 dump_pal(framebuf);
3803
3804
2/2
✓ Branch 0 taken 7943821 times.
✓ Branch 1 taken 173081 times.
8116902 if(!Playing)
3805 173081 black_opening_count=0;
3806
3807
2/2
✓ Branch 0 taken 8062452 times.
✓ Branch 1 taken 54450 times.
8116902 if(black_opening_count<0) //shape is opening up
3808 {
3809 54450 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3810
3811
2/4
✓ Branch 0 taken 54450 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54450 times.
54450 if(Advance||(!Paused))
3812 {
3813 54450 ++black_opening_count;
3814 54450 }
3815 54450 }
3816
2/2
✓ Branch 0 taken 8041926 times.
✓ Branch 1 taken 20526 times.
8062452 else if(black_opening_count>0) //shape is closing
3817 {
3818 20526 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3819
3820
2/4
✓ Branch 0 taken 20526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20526 times.
20526 if(Advance||(!Paused))
3821 {
3822 20526 --black_opening_count;
3823 20526 }
3824 20526 }
3825
3826
3/4
✓ Branch 0 taken 8043062 times.
✓ Branch 1 taken 73840 times.
✓ Branch 2 taken 8043062 times.
✗ Branch 3 not taken.
8116902 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3827 {
3828 black_opening_shape = bosCIRCLE;
3829 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3830 refreshTints();
3831 refreshpal=true;
3832 }
3833
3834
2/2
✓ Branch 0 taken 7871988 times.
✓ Branch 1 taken 244914 times.
8116902 if(refreshpal)
3835 {
3836 244914 refreshpal=false;
3837 244914 RAMpal[253] = _RGB(0,0,0);
3838 244914 RAMpal[254] = _RGB(63,63,63);
3839 244914 hw_palette = &RAMpal;
3840 244914 update_hw_pal = true;
3841
3842 244914 create_rgb_table(&rgb_table, RAMpal, NULL);
3843 244914 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3844 244914 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3845
3846
2/2
✓ Branch 0 taken 62697984 times.
✓ Branch 1 taken 244914 times.
62942898 for(int32_t q=0; q<PAL_SIZE; q++)
3847 {
3848 62697984 trans_table2.data[0][q] = q;
3849 62697984 trans_table2.data[q][q] = q;
3850 62697984 }
3851 244914 }
3852
3853 8116902 bool clearwavy = (wavy <= 0);
3854
3855
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 8109657 times.
8116902 if(wavy <= 0)
3856 {
3857 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3858 8109657 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3859 8109657 }
3860
3861 8116902 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3862
3863
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 8085951 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
8116902 if(wavy && Playing && allowwavy)
3864 {
3865 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3866 30701 }
3867
3868
2/2
✓ Branch 0 taken 8109657 times.
✓ Branch 1 taken 7245 times.
8116902 if(clearwavy)
3869 8109657 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3870
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3871 7245 wavy--; // Wavy was set by a script. Decrement it.
3872
3873
5/6
✓ Branch 0 taken 7943821 times.
✓ Branch 1 taken 173081 times.
✓ Branch 2 taken 184496 times.
✓ Branch 3 taken 7759325 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 184496 times.
8116902 if(Playing && msgpos && !screenscrolling)
3874 {
3875
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_bg_display_buf->clip))
3876 184496 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3877
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_portrait_display_buf->clip))
3878 184496 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3879
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_txt_display_buf->clip))
3880 184496 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3881 184496 }
3882
3883 /*
3884 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3885 {
3886 BITMAP* subBmp = 0;
3887 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3888 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3889 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3890 destroy_bitmap(subBmp);
3891 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3892 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3893 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3894 }
3895 */
3896
3897
2/2
✓ Branch 0 taken 8079385 times.
✓ Branch 1 taken 37517 times.
8116902 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3898
3899
2/2
✓ Branch 0 taken 8084010 times.
✓ Branch 1 taken 32892 times.
8116902 if(nosubscr)
3900 {
3901 32892 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3902 32892 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3903 32892 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3904 32892 }
3905
3906 //TODO: Optimize blit 'overcalls' -Gleeok
3907
2/2
✓ Branch 0 taken 32892 times.
✓ Branch 1 taken 8084010 times.
8116902 BITMAP *source = nosubscr ? panorama : wavybuf;
3908 8116902 blit(source,framebuf,0,0,0,0,256,224);
3909
3910 8116902 update_hw_screen();
3911 8116902 }
3912
3913 //----------------------------------------------------------------
3914
3915 static PALETTE syspal;
3916 int32_t onGUISnapshot()
3917 {
3918 char buf[200];
3919 int32_t num=0;
3920 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3921 do
3922 {
3923 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3924 }
3925 while(num<99999 && exists(buf));
3926
3927 BITMAP *b = create_bitmap_ex(8,resx,resy);
3928
3929 if(b)
3930 {
3931 blit(screen,b,0,0,0,0,resx,resy);
3932 save_bitmap(buf,b,RAMpal);
3933 destroy_bitmap(b);
3934 }
3935
3936 return D_O_K;
3937 }
3938
3939 int32_t onNonGUISnapshot()
3940 {
3941 PALETTE temppal;
3942 get_palette(temppal);
3943 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3944
3945 char buf[200];
3946 int32_t num=0;
3947
3948 do
3949 {
3950 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3951 }
3952 while(num<99999 && exists(buf));
3953
3954 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3955
3956 return D_O_K;
3957 }
3958
3959 int32_t onSnapshot()
3960 {
3961 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3962 {
3963 onGUISnapshot();
3964 }
3965 else
3966 {
3967 onNonGUISnapshot();
3968 }
3969
3970 return D_O_K;
3971 }
3972
3973 int32_t onSaveMapPic()
3974 {
3975 int32_t mapres2 = 0;
3976 char buf[200];
3977 int32_t num=0;
3978 mapscr tmpscr_b[2];
3979 mapscr tmpscr_c[6];
3980 BITMAP* _screen_draw_buffer = NULL;
3981 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3982 set_clip_state(_screen_draw_buffer,1);
3983
3984 for(int32_t i=0; i<6; ++i)
3985 {
3986 tmpscr_c[i] = tmpscr2[i];
3987 tmpscr2[i].zero_memory();
3988
3989 if(i>=2)
3990 {
3991 continue;
3992 }
3993
3994 tmpscr_b[i] = tmpscr[i];
3995 tmpscr[i].zero_memory();
3996 }
3997
3998 do
3999 {
4000 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4001 }
4002 while(num<99999 && exists(buf));
4003
4004 BITMAP* mappic = NULL;
4005
4006
4007 bool done=false, redraw=true;
4008
4009 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4010
4011 if(!mappic)
4012 {
4013 enter_sys_pal();
4014 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4015 exit_sys_pal();
4016 return D_O_K;;
4017 }
4018
4019 // draw the map
4020 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4021
4022 for(int32_t y=0; y<8; y++)
4023 {
4024 for(int32_t x=0; x<16; x++)
4025 {
4026 if(!displayOnMap(x, y))
4027 {
4028 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4029 }
4030 else
4031 {
4032 int32_t s = (y<<4) + x;
4033 loadscr2(1,s,-1);
4034
4035 for(int32_t i=0; i<6; i++)
4036 {
4037 if(tmpscr[1].layermap[i]<=0)
4038 continue;
4039
4040 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4041 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4042 {
4043 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4044
4045 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4046 }
4047 }
4048
4049 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4050
4051 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4052
4053 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4054 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4055
4056 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4057
4058 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4059 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4060 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4061 {
4062 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4063 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4064 }
4065 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4066
4067 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4068
4069 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4070 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4071 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4072 {
4073 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4074 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4075 }
4076 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4077 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4078
4079 }
4080
4081 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4082 }
4083 }
4084
4085 for(int32_t i=0; i<6; ++i)
4086 {
4087 tmpscr2[i]=tmpscr_c[i];
4088
4089 if(i>=2)
4090 {
4091 continue;
4092 }
4093
4094 tmpscr[i]=tmpscr_b[i];
4095 }
4096
4097 save_bitmap(buf,mappic,RAMpal);
4098 destroy_bitmap(mappic);
4099 destroy_bitmap(_screen_draw_buffer);
4100 return D_O_K;
4101 }
4102
4103 13 void f_Quit(int32_t type)
4104 {
4105
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(type==qQUIT && !Playing)
4106 return;
4107
4108 13 bool from_menu = is_sys_pal;
4109
4110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4111 {
4112 13 music_pause();
4113 13 pause_all_sfx();
4114 13 sys_mouse();
4115 13 }
4116 13 enter_sys_pal();
4117 13 clear_keybuf();
4118
4119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_version_check(0, 10))
4120 13 replay_poll();
4121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_is_replaying())
4122 13 replay_peek_quit();
4123
4124
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (!replay_is_replaying())
4125 switch(type)
4126 {
4127 case qQUIT:
4128 onQuit();
4129 break;
4130
4131 case qRESET:
4132 onReset();
4133 break;
4134
4135 case qEXIT:
4136 onExit();
4137 break;
4138 }
4139
4140
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Quit)
4141 {
4142 13 kill_sfx();
4143 13 music_stop();
4144 13 exit_sys_pal();
4145 13 update_hw_screen();
4146 13 }
4147 else
4148 {
4149 exit_sys_pal();
4150 if(!from_menu)
4151 {
4152 music_resume();
4153 resume_all_sfx();
4154 }
4155 }
4156
4157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4158 13 game_mouse();
4159 13 eat_buttons();
4160
4161 13 zc_readrawkey(KEY_ESC);
4162
4163 13 zc_readrawkey(KEY_ENTER);
4164 13 }
4165
4166 //----------------------------------------------------------------
4167
4168 int32_t onNoWalls()
4169 {
4170 cheats_enqueue(Cheat::Walls);
4171 return D_O_K;
4172 }
4173
4174 int32_t onIgnoreSideview()
4175 {
4176 cheats_enqueue(Cheat::IgnoreSideView);
4177 return D_O_K;
4178 }
4179
4180 8116819 int32_t input_idle(bool checkmouse)
4181 {
4182 static int32_t mx, my, mz, mb;
4183
4184
4/6
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127845 times.
✓ Branch 3 taken 5988974 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2127845 times.
10244664 if(keypressed() || zc_key_pressed() ||
4185
4/8
✓ Branch 0 taken 2127845 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127845 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2127845 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2127845 times.
✗ Branch 7 not taken.
2127845 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4186 {
4187 5988974 idle_count = 0;
4188
4189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5988974 times.
5988974 if(active_count < MAX_ACTIVE)
4190 {
4191 5988974 ++active_count;
4192 5988974 }
4193 5988974 }
4194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127845 times.
2127845 else if(idle_count < MAX_IDLE)
4195 {
4196 2127845 ++idle_count;
4197 2127845 active_count = 0;
4198 2127845 }
4199
4200 8116819 mx = mouse_x;
4201 8116819 my = mouse_y;
4202 8116819 mz = mouse_z;
4203 8116819 mb = mouse_b;
4204
4205 8116819 return idle_count;
4206 }
4207
4208 int32_t onGoFast()
4209 {
4210 cheats_enqueue(Cheat::Fast);
4211 return D_O_K;
4212 }
4213
4214 int32_t onKillCheat()
4215 {
4216 cheats_enqueue(Cheat::Kill);
4217 return D_O_K;
4218 }
4219
4220 int32_t onSecretsCheat()
4221 {
4222 cheats_enqueue(Cheat::TrigSecrets);
4223 return D_O_K;
4224 }
4225 int32_t onSecretsCheatPerm()
4226 {
4227 cheats_enqueue(Cheat::TrigSecretsPerm);
4228 return D_O_K;
4229 }
4230
4231 int32_t onShowLayer0()
4232 {
4233 show_layer_0 = !show_layer_0;
4234 return D_O_K;
4235 }
4236 int32_t onShowLayer1()
4237 {
4238 show_layer_1 = !show_layer_1;
4239 return D_O_K;
4240 }
4241 int32_t onShowLayer2()
4242 {
4243 show_layer_2 = !show_layer_2;
4244 return D_O_K;
4245 }
4246 int32_t onShowLayer3()
4247 {
4248 show_layer_3 = !show_layer_3;
4249 return D_O_K;
4250 }
4251 int32_t onShowLayer4()
4252 {
4253 show_layer_4 = !show_layer_4;
4254 return D_O_K;
4255 }
4256 int32_t onShowLayer5()
4257 {
4258 show_layer_5 = !show_layer_5;
4259 return D_O_K;
4260 }
4261 int32_t onShowLayer6()
4262 {
4263 show_layer_6 = !show_layer_6;
4264 return D_O_K;
4265 }
4266 int32_t onShowLayerO()
4267 {
4268 show_layer_over=!show_layer_over;
4269 return D_O_K;
4270 }
4271 int32_t onShowLayerP()
4272 {
4273 show_layer_push=!show_layer_push;
4274 return D_O_K;
4275 }
4276 int32_t onShowLayerS()
4277 {
4278 show_sprites=!show_sprites;
4279 return D_O_K;
4280 }
4281 int32_t onShowLayerF()
4282 {
4283 show_ffcs=!show_ffcs;
4284 return D_O_K;
4285 }
4286 int32_t onShowLayerW()
4287 {
4288 show_walkflags=!show_walkflags;
4289 if(show_walkflags)
4290 show_effectflags = false;
4291 return D_O_K;
4292 }
4293 int32_t onShowLayerE()
4294 {
4295 show_effectflags=!show_effectflags;
4296 if(show_effectflags)
4297 show_walkflags = false;
4298 return D_O_K;
4299 }
4300 int32_t onShowFFScripts()
4301 {
4302 show_ff_scripts=!show_ff_scripts;
4303 return D_O_K;
4304 }
4305 int32_t onShowHitboxes()
4306 {
4307 show_hitboxes=!show_hitboxes;
4308 return D_O_K;
4309 }
4310 int32_t onShowInfoOpacity()
4311 {
4312 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4313 zc_set_config("zc","debug_info_opacity",info_opacity);
4314 return D_O_K;
4315 }
4316
4317 int32_t onLightSwitch()
4318 {
4319 cheats_enqueue(Cheat::Light);
4320 return D_O_K;
4321 }
4322
4323 int32_t onGoTo();
4324 int32_t onGoToComplete();
4325
4326 8116819 void syskeys()
4327 {
4328 8116819 update_system_keys();
4329
4330 int32_t oldtitle_version;
4331
4332
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(close_button_quit)
4333 {
4334 close_button_quit=false;
4335 f_Quit(qEXIT);
4336 }
4337
4338 8116819 poll_joystick();
4339
4340
2/10
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8116819 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8116819 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4341 {
4342 oldtitle_version=title_version;
4343 System();
4344 }
4345
4346 8116819 mouse_down=gui_mouse_b();
4347
4348
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(zc_read_system_key(KEY_F1))
4349 {
4350 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4351 {
4352 halt=!halt;
4353 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4354 }
4355 else
4356 {
4357 Throttlefps=!Throttlefps;
4358 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4359 logic_counter=0;
4360 }
4361 }
4362
4363 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4364 /*
4365 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4366 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4367 */
4368
4369
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(zc_read_system_key(KEY_F2))
4370 {
4371 ShowFPS=!ShowFPS;
4372 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4373 }
4374
4375
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8116819 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8116819 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4376
4377
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8116819 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8116819 if(zc_read_system_key(KEY_F4) && Playing)
4378 {
4379 Paused=true;
4380 Advance=true;
4381 }
4382
4383
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(zc_read_system_key(KEY_F6)) onTryQuit();
4384
4385 #ifndef ALLEGRO_MACOSX
4386
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4387
4388
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4389 #else
4390 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4391
4392 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4393 #endif
4394
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8116819 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8116819 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4395
4396
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if (zc_read_system_key(KEY_F12))
4397 {
4398 onSnapshot();
4399 }
4400
4401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8116819 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8116819 if(debug_enabled && zc_read_system_key(KEY_TAB))
4402 set_debug(!get_debug());
4403
4404
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(CheatModifierKeys())
4405 {
4406 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4407 {
4408 if(!bindable_cheat(c))
4409 continue;
4410 if(get_debug() || cheat >= cheat_lvl(c))
4411 {
4412 if(checkcheat(c))
4413 cheats_hit_bind(c);
4414 }
4415 }
4416 }
4417
4418
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(volkeys)
4419 {
4420 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4421
4422 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4423
4424 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4425
4426 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4427 }
4428
4429
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8116819 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8116819 if(!get_debug() || !SystemKeys || replay_is_replaying())
4430 8116819 goto bottom;
4431
4432 if(zc_readkey(KEY_D))
4433 {
4434 details = !details;
4435 rectfill(screen,0,0,319,7,BLACK);
4436 rectfill(screen,0,8,31,239,BLACK);
4437 rectfill(screen,288,8,319,239,BLACK);
4438 rectfill(screen,32,232,287,239,BLACK);
4439 }
4440
4441 if(zc_readkey(KEY_P)) Paused=!Paused;
4442
4443 //if(zc_readkey(KEY_P)) centerHero();
4444 if(zc_readkey(KEY_A))
4445 {
4446 Paused=true;
4447 Advance=true;
4448 }
4449
4450 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4451 #ifndef ALLEGRO_MACOSX
4452 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4453
4454 if(zc_readkey(KEY_F7))
4455 {
4456 Matrix(ss_speed, ss_density, 0);
4457 game_pal();
4458 }
4459 #else
4460 // The reason these are different on Mac in the first place is that
4461 // the OS doesn't let us use F9 and F10...
4462 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4463
4464 if(zc_readkey(KEY_F9))
4465 {
4466 Matrix(ss_speed, ss_density, 0);
4467 game_pal();
4468 }
4469 #endif
4470 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4471 {
4472 //change containers
4473 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4474 {
4475 //magic containers
4476 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4477 {
4478 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4479 }
4480 else
4481 {
4482 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4483 }
4484 }
4485 else
4486 {
4487 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4488 {
4489 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4490 }
4491 else
4492 {
4493 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4494 }
4495 }
4496 }
4497
4498 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4499 {
4500 //change containers
4501 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4502 {
4503 //magic containers
4504 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4505 {
4506 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4507 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4508 //heart containers
4509 }
4510 else
4511 {
4512 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4513 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4514 }
4515 }
4516 else
4517 {
4518 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4519 {
4520 game->set_magic(zc_max(game->get_magic()-1,0));
4521 }
4522 else
4523 {
4524 game->set_life(zc_max(game->get_life()-1,0));
4525 }
4526 }
4527 }
4528
4529 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4530
4531 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4532
4533 verifyBothWeapons();
4534
4535 bottom:
4536
4537
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(input_idle(true) > after_time())
4538 {
4539 Matrix(ss_speed, ss_density, 0);
4540 game_pal();
4541 }
4542 8116819 }
4543
4544 425520 void checkQuitKeys()
4545 {
4546 #ifndef ALLEGRO_MACOSX
4547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425520 times.
425520 if(key[KEY_F9]) f_Quit(qRESET);
4548
4549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425520 times.
425520 if(key[KEY_F10]) f_Quit(qEXIT);
4550 #else
4551 if(key[KEY_F7]) f_Quit(qRESET);
4552
4553 if(key[KEY_F8]) f_Quit(qEXIT);
4554 #endif
4555 425520 }
4556
4557 8116819 bool CheatModifierKeys()
4558 {
4559 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4560 // to trigger cheats.
4561
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if (replay_is_replaying())
4562 8116819 return false;
4563
4564 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4565 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4566 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4567 {
4568 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4569 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4570 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4571 {
4572 return true;
4573 }
4574 }
4575 return false;
4576 8116819 }
4577
4578 //99:05:54, for some reason?
4579 #define OLDMAXTIME 21405240
4580 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4581 #define MAXTIME 1944000000
4582
4583 8116902 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4584 {
4585
2/2
✓ Branch 0 taken 7823317 times.
✓ Branch 1 taken 293585 times.
8116902 if(zcmusic!=NULL)
4586 {
4587 293585 zcmusic_poll();
4588 293585 }
4589
4590 8116902 updatescr(allowwavy);
4591
4592 8116902 Advance=false;
4593
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8116902 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8116902 times.
8116902 while(Paused && !Advance && !Quit)
4594 {
4595 // have to call this, otherwise we'll get an infinite loop
4596 syskeys();
4597 if(allowF6Script)
4598 {
4599 FFCore.runF6Engine();
4600 }
4601 throttleFPS();
4602
4603 #ifdef _WIN32
4604
4605 if(use_dwm_flush)
4606 {
4607 do_DwmFlush();
4608 }
4609
4610 #endif
4611
4612 // to keep music playing
4613 if(zcmusic!=NULL)
4614 {
4615 zcmusic_poll();
4616 }
4617
4618 update_hw_screen();
4619 }
4620
4621
2/2
✓ Branch 0 taken 8116831 times.
✓ Branch 1 taken 71 times.
8116902 if(Quit)
4622 71 return;
4623
4624
3/4
✓ Branch 0 taken 7943812 times.
✓ Branch 1 taken 173019 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7943812 times.
8116831 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4625 7943812 game->change_time(1);
4626
4627 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4628
4629
2/2
✓ Branch 0 taken 6610697 times.
✓ Branch 1 taken 1506134 times.
8116831 if (replay_version_check(11, 16))
4630
2/2
✓ Branch 0 taken 27110412 times.
✓ Branch 1 taken 1506134 times.
28616546 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4631 28616546 down_control_states[i] = raw_control_state[i];
4632
4633
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8116833 times.
8116831 if (replay_is_active())
4634 {
4635
2/2
✓ Branch 0 taken 1270465 times.
✓ Branch 1 taken 6846368 times.
8116833 if (replay_version_check(3))
4636 6846368 replay_poll();
4637
4638
4/4
✓ Branch 0 taken 6603555 times.
✓ Branch 1 taken 1513264 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6503020 times.
8116833 if (replay_version_check(11) || replay_version_check(6, 8))
4639 1613799 replay_peek_input();
4640 8116819 }
4641
4642 8116831 load_control_called_this_frame = false;
4643
4644 8116831 poll_keyboard();
4645 8116831 update_keys();
4646
4647 8116831 ++frame;
4648
4649
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8116819 times.
8116831 if (replay_is_replaying())
4650 8116819 replay_do_cheats();
4651 8116831 syskeys();
4652
4653 // The mouse variables can change from the mouse thread at anytime during a frame,
4654 // so save the result at the start so that replaying is consistent.
4655 8116831 script_mouse_x = gui_mouse_x();
4656 8116831 script_mouse_y = gui_mouse_y();
4657 8116831 script_mouse_z = mouse_z;
4658 8116831 script_mouse_b = mouse_b;
4659
4660 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4661 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4662 // approach here means it doesn't matter which call adds the cheat.
4663 8116831 cheats_execute_queued();
4664
4665
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8116819 times.
8116831 if (replay_is_replaying())
4666 8116819 replay_peek_quit();
4667
2/2
✓ Branch 0 taken 8116818 times.
✓ Branch 1 taken 13 times.
8116831 if (GameFlags & GAMEFLAG_TRYQUIT)
4668 13 replay_step_quit(0);
4669
2/2
✓ Branch 0 taken 2932 times.
✓ Branch 1 taken 8113899 times.
8116831 if(allowF6Script)
4670 8113899 FFCore.runF6Engine();
4671
2/2
✓ Branch 0 taken 8116601 times.
✓ Branch 1 taken 230 times.
8116831 if (Quit)
4672 230 replay_step_quit(Quit);
4673 // Someday... maybe install a Turbo button here?
4674 8116831 throttleFPS();
4675
4676 #ifdef _WIN32
4677
4678 if(use_dwm_flush)
4679 {
4680 do_DwmFlush();
4681 }
4682
4683 #endif
4684
4685 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4686
2/2
✓ Branch 0 taken 46694 times.
✓ Branch 1 taken 8070137 times.
8116831 if(sfxcleanup)
4687 8070137 sfx_cleanup();
4688 8116902 }
4689
4690 70 void zapout()
4691 {
4692 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4693 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4694
4695 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4696 70 script_drawing_commands.Clear();
4697
4698 // zap out
4699
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=1; i<=24; i++)
4700 {
4701 1680 draw_fuzzy(i);
4702 1680 advanceframe(true);
4703
4704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4705 {
4706 break;
4707 }
4708 1680 }
4709 70 }
4710
4711 70 void zapin()
4712 {
4713 70 FFCore.warpScriptCheck();
4714 70 draw_screen(tmpscr);
4715 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4716 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4717 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4718
4719 // zap out
4720 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4721
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=24; i>=1; i--)
4722 {
4723 1680 draw_fuzzy(i);
4724 1680 advanceframe(true);
4725
4726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4727 {
4728 break;
4729 }
4730 1680 }
4731 70 }
4732
4733
4734 38 void wavyout(bool showhero)
4735 {
4736 38 draw_screen(tmpscr, showhero);
4737 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4738
4739 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4740 38 clear_to_color(wavebuf,0);
4741 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4742
4743 static PALETTE wavepal;
4744
4745 int32_t ofs;
4746 38 int32_t amplitude=8;
4747
4748 38 int32_t wavelength=4;
4749 38 double palpos=0, palstep=4, palstop=126;
4750
4751 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4752
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4753 {
4754
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4755 {
4756 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4757 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4758 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4759 408576 }
4760
4761 1596 palpos+=palstep;
4762
4763
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4764 {
4765 1596 hw_palette = &wavepal;
4766 1596 update_hw_pal = true;
4767 1596 }
4768 else
4769 {
4770 hw_palette = &RAMpal;
4771 update_hw_pal = true;
4772 }
4773
4774
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4775 {
4776
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4777 {
4778 68640768 ofs=0;
4779
4780
4/4
✓ Branch 0 taken 33503232 times.
✓ Branch 1 taken 35137536 times.
✓ Branch 2 taken 16751616 times.
✓ Branch 3 taken 16751616 times.
68640768 if((j<i)&&(j&1))
4781 {
4782 16751616 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4783 16751616 }
4784
4785 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4786 68640768 }
4787 268128 }
4788
4789 1596 advanceframe(true);
4790
4791 // animate_combos();
4792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4793 break;
4794 1596 }
4795
4796 38 destroy_bitmap(wavebuf);
4797 38 }
4798
4799 38 void wavyin()
4800 {
4801 38 draw_screen(tmpscr);
4802 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4803
4804 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4805 38 clear_to_color(wavebuf,0);
4806 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4807
4808 static PALETTE wavepal;
4809
4810 //Breaks dark rooms.
4811 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4812 /*
4813 loadfullpal();
4814 loadlvlpal(DMaps[currdmap].color);
4815 ringcolor(false);
4816 */
4817 38 refreshpal=false;
4818 int32_t ofs;
4819 38 int32_t amplitude=8;
4820 38 int32_t wavelength=4;
4821 38 double palpos=168, palstep=4, palstop=126;
4822
4823 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4824
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4825 {
4826
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4827 {
4828 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4829 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4830 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4831 408576 }
4832
4833 1596 palpos-=palstep;
4834
4835
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4836 {
4837 1596 hw_palette = &wavepal;
4838 1596 update_hw_pal = true;
4839 1596 }
4840 else
4841 {
4842 hw_palette = &RAMpal;
4843 update_hw_pal = true;
4844 }
4845
4846
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4847 {
4848
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4849 {
4850 68640768 ofs=0;
4851
4852
4/4
✓ Branch 0 taken 34728960 times.
✓ Branch 1 taken 33911808 times.
✓ Branch 2 taken 17568768 times.
✓ Branch 3 taken 17160192 times.
68640768 if((j<(167-i))&&(j&1))
4853 {
4854 17160192 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4855 17160192 }
4856
4857 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4858 68640768 }
4859 268128 }
4860
4861 1596 advanceframe(true);
4862 // animate_combos();
4863
4864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4865 break;
4866 1596 }
4867
4868 38 destroy_bitmap(wavebuf);
4869 38 }
4870
4871 1921 void blackscr(int32_t fcnt,bool showsubscr)
4872 {
4873 1921 reset_pal_cycling();
4874 1921 script_drawing_commands.Clear();
4875
4876 1921 FFCore.warpScriptCheck();
4877 1921 bool showtime = game->should_show_time();
4878
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 57560 times.
59481 while(fcnt>0)
4879 {
4880 57560 clear_bitmap(framebuf);
4881
4882
2/2
✓ Branch 0 taken 19710 times.
✓ Branch 1 taken 37850 times.
57560 if(showsubscr)
4883 {
4884 37850 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4885
3/4
✓ Branch 0 taken 37850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 37100 times.
37850 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4886 {
4887 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4888 750 }
4889 37850 }
4890
4891 57560 advanceframe(true);
4892
4893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57560 times.
57560 if(Quit)
4894 break;
4895
4896 57560 --fcnt;
4897 }
4898 1921 }
4899
4900 729 void openscreen(int32_t shape)
4901 {
4902 729 reset_pal_cycling();
4903 729 black_opening_count=0;
4904
4905
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
729 if(COOLSCROLL || shape>-1)
4906 {
4907 630 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4908 630 return;
4909 }
4910 else
4911 {
4912 99 Hero.setDontDraw(true);
4913 99 show_subscreen_dmap_dots=false;
4914 99 show_subscreen_numbers=false;
4915 // show_subscreen_items=false;
4916 99 show_subscreen_life=false;
4917 }
4918
4919 99 int32_t x=128;
4920
4921 99 FFCore.warpScriptCheck();
4922
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 7920 times.
8019 for(int32_t i=0; i<80; i++)
4923 {
4924 7920 draw_screen(tmpscr);
4925 //? draw_screen already draws the subscreen -DD
4926 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4927 7920 x=128-(((i*128/80)/8)*8);
4928
4929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(x>0)
4930 {
4931 7920 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4932 7920 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4933 7920 }
4934
4935 7920 advanceframe(true);
4936
4937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(Quit)
4938 {
4939 break;
4940 }
4941 7920 }
4942
4943 99 Hero.setDontDraw(false);
4944 99 show_subscreen_items=true;
4945 99 show_subscreen_dmap_dots=true;
4946 729 }
4947
4948 void closescreen(int32_t shape)
4949 {
4950 reset_pal_cycling();
4951 black_opening_count=0;
4952
4953 if(COOLSCROLL || shape>-1)
4954 {
4955 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4956 return;
4957 }
4958 else
4959 {
4960 Hero.setDontDraw(true);
4961 show_subscreen_dmap_dots=false;
4962 show_subscreen_numbers=false;
4963 // show_subscreen_items=false;
4964 show_subscreen_life=false;
4965 }
4966
4967 int32_t x=128;
4968
4969 FFCore.warpScriptCheck();
4970 for(int32_t i=79; i>=0; --i)
4971 {
4972 draw_screen(tmpscr);
4973 //? draw_screen already draws the subscreen -DD
4974 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4975 x=128-(((i*128/80)/8)*8);
4976
4977 if(x>0)
4978 {
4979 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4980 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4981 }
4982
4983 advanceframe(true);
4984
4985 if(Quit)
4986 {
4987 break;
4988 }
4989 }
4990
4991 Hero.setDontDraw(false);
4992 show_subscreen_items=true;
4993 show_subscreen_dmap_dots=true;
4994 }
4995
4996 179 int32_t TriforceCount()
4997 {
4998 179 int32_t c=0;
4999
5000
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5001
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5002 1044 ++c;
5003
5004 179 return c;
5005 }
5006
5007 int32_t onCustomGame()
5008 {
5009 int32_t file = getsaveslot();
5010
5011 if(file < 0)
5012 return D_O_K;
5013
5014 bool ret = (custom_game(file)!=0);
5015 return ret ? D_CLOSE : D_O_K;
5016 }
5017
5018 int32_t onContinue()
5019 {
5020 return D_CLOSE;
5021 }
5022
5023 int32_t onEsc() // Unused?? -L
5024 {
5025 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5026 }
5027
5028 int32_t onVsync()
5029 {
5030 Throttlefps = !Throttlefps;
5031 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5032 return D_O_K;
5033 }
5034
5035 int32_t onWinPosSave()
5036 {
5037 SaveWinPos = !SaveWinPos;
5038 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5039 return D_O_K;
5040 }
5041 int32_t onIntegerScaling()
5042 {
5043 scaleForceInteger = !scaleForceInteger;
5044 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5045 return D_O_K;
5046 }
5047 int32_t onStretchGame()
5048 {
5049 stretchGame = !stretchGame;
5050 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5051 return D_O_K;
5052 }
5053
5054 int32_t onClickToFreeze()
5055 {
5056 ClickToFreeze = !ClickToFreeze;
5057 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5058 return D_O_K;
5059 }
5060
5061 int32_t OnSaveZCConfig()
5062 {
5063 if(jwin_alert3(
5064 "Save Configuration",
5065 "Are you sure that you wish to save your present configuration settings?",
5066 "This will overwrite your prior settings!",
5067 NULL,
5068 "&Yes",
5069 "&No",
5070 NULL,
5071 'y',
5072 'n',
5073 0,
5074 get_zc_font(font_lfont)) == 1)
5075 {
5076 save_game_configs();
5077 return D_O_K;
5078 }
5079 else return D_O_K;
5080 }
5081
5082 int32_t OnnClearQuestDir()
5083 {
5084 if(jwin_alert3(
5085 "Clear Current Directory Cache",
5086 "Are you sure that you wish to clear the current cached directory?",
5087 "This will default the current directory to the ROOT for this instance of ZC Player!",
5088 NULL,
5089 "&Yes",
5090 "&No",
5091 NULL,
5092 'y',
5093 'n',
5094 0,
5095 get_zc_font(font_lfont)) == 1)
5096 {
5097 zc_set_config("zeldadx","win_qst_dir","");
5098 flush_config_file();
5099 strcpy(qstdir,"");
5100 #ifdef __EMSCRIPTEN__
5101 em_sync_fs();
5102 #endif
5103 return D_O_K;
5104 }
5105 else return D_O_K;
5106 }
5107
5108
5109 int32_t onConsoleZASM()
5110 {
5111 if ( !zasm_debugger )
5112 {
5113 AlertDialog("WARNING: ZASM Debugger",
5114 "Enabling this will open the ZASM Debugger Console"
5115 "\nThis will likely grind ZC to a halt with lag."
5116 "\nTo make any use of this, it is suggested that you read"
5117 "\nthe documentation for 'void Breakpoint(char[] string);'"
5118 " in 'ZScript_Additions.txt'"
5119 "\nThis is not recommended for normal users,"
5120 " and is only intended for ZC developers,"
5121 "\nor quest developers coding directly in ZASM"
5122 "\nAre you sure that you wish to open the ZASM Debugger?",
5123 [&](bool ret,bool)
5124 {
5125 if(ret)
5126 {
5127 FFCore.ZASMPrint(true);
5128 }
5129 }).show();
5130 return D_O_K;
5131 }
5132 else
5133 {
5134 FFCore.ZASMPrint(false);
5135 return D_O_K;
5136 }
5137 }
5138
5139
5140 int32_t onConsoleZScript()
5141 {
5142 if ( !zscript_debugger )
5143 {
5144 AlertDialog("ZScript Debugger",
5145 "Enabling this will open the ZScript Debugger Console"
5146 "\nThis will display any messages logged by scripts,"
5147 " including script errors."
5148 "\nAre you sure that you wish to open the ZScript Debugger?",
5149 [&](bool ret,bool)
5150 {
5151 if(ret)
5152 {
5153 FFCore.ZScriptConsole(true);
5154 }
5155 }).show();
5156 return D_O_K;
5157 }
5158 else
5159 {
5160 FFCore.ZScriptConsole(false);
5161 return D_O_K;
5162 }
5163 }
5164
5165 int32_t onClrConsoleOnReload()
5166 {
5167 clearConsoleOnReload = !clearConsoleOnReload;
5168 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5169 return D_O_K;
5170 }
5171 int32_t onClrConsoleOnLoad()
5172 {
5173 clearConsoleOnLoad = !clearConsoleOnLoad;
5174 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5175 return D_O_K;
5176 }
5177
5178
5179 int32_t onFrameSkip()
5180 {
5181 FrameSkip = !FrameSkip;
5182 return D_O_K;
5183 }
5184
5185 int32_t onSaveDragResize()
5186 {
5187 SaveDragResize = !SaveDragResize;
5188 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5189 return D_O_K;
5190 }
5191
5192 int32_t onDragAspect()
5193 {
5194 DragAspect = !DragAspect;
5195 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5196 return D_O_K;
5197 }
5198
5199 int32_t onTransLayers()
5200 {
5201 TransLayers = !TransLayers;
5202 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5203 return D_O_K;
5204 }
5205
5206 int32_t onNESquit()
5207 {
5208 NESquit = !NESquit;
5209 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5210 return D_O_K;
5211 }
5212
5213 int32_t onVolKeys()
5214 {
5215 volkeys = !volkeys;
5216 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5217 return D_O_K;
5218 }
5219
5220 int32_t onShowFPS()
5221 {
5222 ShowFPS = !ShowFPS;
5223 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5224 return D_O_K;
5225 }
5226
5227 957784642 bool is_Fkey(int32_t k)
5228 {
5229
2/2
✓ Branch 0 taken 97401828 times.
✓ Branch 1 taken 860382814 times.
957784642 switch(k)
5230 {
5231 case KEY_F1:
5232 case KEY_F2:
5233 case KEY_F3:
5234 case KEY_F4:
5235 case KEY_F5:
5236 case KEY_F6:
5237 case KEY_F7:
5238 case KEY_F8:
5239 case KEY_F9:
5240 case KEY_F10:
5241 case KEY_F11:
5242 case KEY_F12:
5243 97401828 return true;
5244 }
5245
5246 860382814 return false;
5247 957784642 }
5248
5249 void kb_getkey(DIALOG *d);
5250
5251 //Used by all keyboard key settings dialogues.
5252 void kb_clearjoystick(DIALOG *d)
5253 {
5254 d->flags|=D_SELECTED;
5255
5256 jwin_button_proc(MSG_DRAW,d,0);
5257 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5258 // text_mode(vc(11));
5259 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5260 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5261
5262 update_hw_screen(true);
5263
5264 clear_keybuf();
5265 int32_t k = next_press_key();
5266 clear_keybuf();
5267
5268 //shnarf
5269 //47=f1
5270 //59=esc
5271 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5272 // *((int32_t*)d->dp3) = k;
5273 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5274
5275
5276 d->flags&=~D_SELECTED;
5277 }
5278
5279 //Clears key to 0.
5280 //Used by all keyboard key settings dialogues.
5281 void kb_clearkey(DIALOG *d);
5282
5283 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5284 {
5285 switch(msg)
5286 {
5287 case MSG_KEY:
5288 case MSG_CLICK:
5289
5290 kb_clearjoystick(d);
5291
5292 while(gui_mouse_b())
5293 {
5294 clear_keybuf();
5295 rest(1);
5296 }
5297
5298 return D_REDRAW;
5299 }
5300
5301 return jwin_button_proc(msg,d,c);
5302 }
5303
5304 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5305 //Only used in keyboard settings dialogues to clear keys.
5306 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5307
5308 void j_getbtn(DIALOG *d)
5309 {
5310 d->flags|=D_SELECTED;
5311 jwin_button_proc(MSG_DRAW,d,0);
5312 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5313 // text_mode(vc(11));
5314 int32_t y = gui_bmp->h/2 - 12;
5315 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5316 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5317 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5318
5319 update_hw_screen(true);
5320
5321 int32_t b = next_press_btn();
5322
5323 if(b>=0)
5324 *((int32_t*)d->dp3) = b;
5325
5326 d->flags&=~D_SELECTED;
5327
5328 if (player)
5329 player->joy_on = TRUE;
5330 }
5331
5332 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5333 {
5334 switch(msg)
5335 {
5336 case MSG_KEY:
5337 case MSG_CLICK:
5338
5339 j_getbtn(d);
5340
5341 while(gui_mouse_b()) {
5342 rest(1);
5343 clear_keybuf();
5344 }
5345
5346 return D_REDRAW;
5347 }
5348
5349 return jwin_button_proc(msg,d,c);
5350 }
5351
5352 //shnarf
5353 extern const char *key_str[];
5354 std::string get_keystr(int key);
5355
5356 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5357 //extern int32_t zcmusic_bufsz;
5358
5359 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5360 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5361
5362 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5363 {
5364 //these are here to bypass compiler warnings about unused arguments
5365 c=c;
5366
5367 if(msg==MSG_DRAW)
5368 {
5369 switch(d->w)
5370 {
5371 case 0:
5372 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5373 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5374 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5375 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5376 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5377 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5378 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5379 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5380 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5381 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5382 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5383 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5384 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5385 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5386 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5387 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5388 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5389 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5390 break;
5391
5392 case 1:
5393 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5394 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5395 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5396 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5397 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5398 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5399 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5400 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5401 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5402 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5403 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5404 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5405 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5406 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5407 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5408 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5409 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5410 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5411 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5412 break;
5413
5414 case 2:
5415 sprintf(str_a," %3d",midi_volume);
5416 sprintf(str_b," %3d",digi_volume);
5417 sprintf(str_l," %3d",emusic_volume);
5418 sprintf(str_m," %3dKB",zcmusic_bufsz);
5419 sprintf(str_r," %3d",sfx_volume);
5420 strcpy(str_s,pan_str[pan_style]);
5421 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5422 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5423 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5424 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5425 break;
5426 }
5427 }
5428
5429 return D_O_K;
5430 }
5431
5432 int32_t set_vol(void *dp3, int32_t d2)
5433 {
5434 switch(((int32_t*)dp3)[0])
5435 {
5436 case 0:
5437 midi_volume = zc_min(d2<<3,255);
5438 break;
5439
5440 case 1:
5441 digi_volume = zc_min(d2<<3,255);
5442 break;
5443
5444 case 2:
5445 emusic_volume = zc_min(d2<<3,255);
5446 break;
5447
5448 case 3:
5449 sfx_volume = zc_min(d2<<3,255);
5450 break;
5451 }
5452
5453 // text_mode(vc(11));
5454 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5455 return D_O_K;
5456 }
5457
5458 int32_t set_pan(void *dp3, int32_t d2)
5459 {
5460 pan_style = vbound(d2,0,3);
5461 // text_mode(vc(11));
5462 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5463 return D_O_K;
5464 }
5465
5466 int32_t set_buf(void *dp3, int32_t d2)
5467 {
5468 // text_mode(vc(11));
5469 zcmusic_bufsz = d2 + 1;
5470 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5471 return D_O_K;
5472 }
5473
5474 static int32_t gamepad_btn_list[] =
5475 {
5476 6,
5477 7,8,9,10,11,12,13,14,15,16,17,
5478 18,19,20,21,22,23,24,25,26,27,28,
5479 29,30,31,32,33,34,35,36,37,38,39,
5480 -1
5481 };
5482
5483 static int32_t gamepad_dirs_list[] =
5484 {
5485 40,41,42,43,
5486 44,45,46,47,
5487 48,49,50,51,
5488 52,53,54,55,
5489 56,
5490 -1
5491 };
5492
5493 static TABPANEL gamepad_tabs[] =
5494 {
5495 // (text)
5496 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5497 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5498 { NULL, 0, NULL, 0, NULL }
5499 };
5500
5501 static DIALOG gamepad_dlg[] =
5502 {
5503 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5504 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5505 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5506 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5507 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5508 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5509 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5510 // 6
5511 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5512 // 7
5513 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5514 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5515 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5516 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5517 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5518 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5519 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5520 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5521 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5522 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5523 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5524 // 18
5525 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5526 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5527 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5528 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5529 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5530 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5531 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5532 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5533 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5534 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5535 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5536 // 29
5537 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5538 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5539 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5540 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5541 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5542 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5543 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5544 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5545 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5546 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5547 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5548 // 40
5549 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5550 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5551 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5552 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5553 // 44
5554 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5555 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5556 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5557 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5558 // 48
5559 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5560 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5561 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5562 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5563 // 52
5564 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5565 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5566 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5567 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5568 // 56
5569 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5570 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5571 };
5572
5573 static int32_t keyboard_keys_list[] =
5574 {
5575 6,7,8,9,10,
5576 11,12,13,14,15,16,17,18,19,20,
5577 21,22,23,24,25,26,27,28,29,30,
5578 31,32,33,34,35,36,37,38,39,40,
5579 -1
5580 };
5581
5582 static int32_t keyboard_dirs_list[] =
5583 {
5584 41,42,43,44,
5585 45,46,47,48,
5586 49,50,51,52,
5587 53,54,55,56,
5588 -1
5589 };
5590
5591 static int32_t keyboard_mods_list[] =
5592 {
5593 57,58,59,60,
5594 61,62,63,64,
5595 65,66,67,68,
5596 69,70,71,72,
5597 -1
5598 };
5599
5600 static TABPANEL keyboard_control_tabs[] =
5601 {
5602 // (text)
5603 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5604 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5605 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5606 { NULL, 0, NULL, 0, NULL }
5607 };
5608
5609 static DIALOG keyboard_control_dlg[] =
5610 {
5611 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5612 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5613 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5614 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5615 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5616 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5617 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5618 // Keys
5619 // 6
5620 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5621 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5622 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5623 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5624 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5625 // 11
5626 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5627 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5628 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5629 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5630 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5631 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5632 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5633 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5634 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5635 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5636 // 21
5637 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5638 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5639 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5640 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5641 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5642 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5643 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5644 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5645 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5646 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5647 // 31
5648 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5649 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5650 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5651 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5652 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5653 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5654 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5655 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5656 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5657 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5658 // Dirs
5659 // 41
5660 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5661 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5662 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5663 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5664 // 45
5665 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5666 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5667 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5668 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5669 // 49
5670 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5671 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5672 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5673 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5674 // 53
5675 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5676 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5677 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5678 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5679 // Mods
5680 // 57
5681 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5682 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5683 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5684 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5685 // 61
5686 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5687 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5688 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5689 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5690 // 65
5691 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5692 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5693 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5694 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5695 // 69
5696 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5697 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5698 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5699 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5700 // 73
5701 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5702 };
5703
5704 /*
5705 int32_t midi_dp[3] = {0,147,104};
5706 int32_t digi_dp[3] = {1,147,120};
5707 int32_t pan_dp[3] = {0,147,136};
5708 int32_t buf_dp[3] = {0,147,152};
5709 */
5710 int32_t midi_dp[3] = {0,0,0};
5711 int32_t digi_dp[3] = {1,0,0};
5712 int32_t emus_dp[3] = {2,0,0};
5713 int32_t buf_dp[3] = {0,0,0};
5714 int32_t sfx_dp[3] = {3,0,0};
5715 int32_t pan_dp[3] = {0,0,0};
5716
5717 static DIALOG sound_dlg[] =
5718 {
5719 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5720 39 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5721 39 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5722 39 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5723 39 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5724 39 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5725 39 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5726 39 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5727 39 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5728 39 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5729 39 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5730 // 10
5731 39 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5732 39 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5733 39 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5734 39 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5735 39 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5736 39 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5737 39 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5738 39 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5739 39 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5740 39 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5741 //20
5742 39 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5743 39 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5744 39 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5745 39 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5746 39 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5747 39 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5748 39 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5749 39 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5750 39 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5751 39 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5752 //30
5753 39 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5754 39 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5755 39 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5756 39 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5757 };
5758
5759 char zc_builddate[80];
5760 char zc_aboutstr[80];
5761
5762 static DIALOG about_dlg[] =
5763 {
5764 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5765 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5766 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5767 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5768 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5769 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5770 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5771 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5772 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5773 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5774 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5775 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5776 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5777 };
5778
5779
5780 static DIALOG quest_dlg[] =
5781 {
5782 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5783 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5784 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5785 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5786 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5787 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5788 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5789 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5790 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5791 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5792 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5793 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5794 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5795 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5796 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5797 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5798 };
5799
5800 static DIALOG triforce_dlg[] =
5801 {
5802 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5803 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5804 // 1
5805 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5806 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5807 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5808 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5809 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5810 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5811 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5812 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5813 // 9
5814 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5815 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5816 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5817 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5818 };
5819
5820 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5821 {
5822 go();
5823 int32_t ret=0;
5824 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5825 comeback();
5826 return ret != 0;
5827 }
5828
5829
5830 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5831 {
5832 if(def!=modulepath)
5833 strcpy(modulepath,def);
5834
5835 if(!usefilename)
5836 {
5837 int32_t i=(int32_t)strlen(modulepath);
5838
5839 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5840 modulepath[i--]=0;
5841 }
5842
5843 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5844 int32_t ret=0;
5845 int32_t sel=0;
5846
5847 if(list==NULL)
5848 {
5849 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5850 }
5851 else
5852 {
5853 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5854 }
5855
5856 return ret!=0;
5857 }
5858
5859 //The Dialogue that loads a ZMOD Module File
5860 int32_t zc_load_zmod_module_file()
5861 {
5862 if ( Playing )
5863 {
5864 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5865 return -1;
5866 }
5867 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5868 return D_CLOSE;
5869
5870 FILE *tempmodule = fopen(modulepath,"r");
5871
5872 if(tempmodule == NULL)
5873 {
5874 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5875 return -1;
5876 }
5877
5878
5879 //Set the module path:
5880 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5881 strcpy(moduledata.module_name, modulepath);
5882 al_trace("New Module Path is: %s \n", moduledata.module_name);
5883 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5884 zcm.init(true); //Load the module values.
5885 moduledata.refresh_title_screen = 1;
5886 // refresh_select_screen = 1;
5887 build_biic_list();
5888 return D_O_K;
5889 }
5890
5891 static DIALOG module_info_dlg[] =
5892 {
5893 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5894
5895
5896 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5897 //1
5898 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5899 //2
5900 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5901 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5902 //4
5903 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5904 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5905 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5906 //7
5907
5908 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5909 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5910 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5911 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5912 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5913 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5914 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5915 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5916 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5917
5918 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5919 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5920 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5921 };
5922
5923 void about_zcplayer_module(const char *prompt,int32_t initialval)
5924 {
5925
5926 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5927 if ( moduledata.moduletitle[0] != 0 )
5928 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5929
5930 if ( moduledata.moduleauthor[0] != 0 )
5931 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5932
5933 if ( moduledata.moduleinfo0[0] != 0 )
5934 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
5935 if ( moduledata.moduleinfo1[0] != 0 )
5936 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
5937 if ( moduledata.moduleinfo2[0] != 0 )
5938 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
5939 if ( moduledata.moduleinfo3[0] != 0 )
5940 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
5941 if ( moduledata.moduleinfo4[0] != 0 )
5942 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
5943
5944 char module_date[255];
5945 memset(module_date, 0, sizeof(module_date));
5946 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
5947 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
5948
5949
5950
5951 char module_vers[255];
5952 memset(module_vers, 0, sizeof(module_vers));
5953 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
5954
5955
5956 //sprintf(tilecount,"%d",1);
5957
5958 char module_build[255];
5959 memset(module_build, 0, sizeof(module_build));
5960 if ( moduledata.modbeta )
5961 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
5962 else
5963 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
5964
5965 module_info_dlg[12].dp = (char*)module_date;
5966 module_info_dlg[13].dp = (char*)module_vers;
5967 module_info_dlg[14].dp = (char*)module_build;
5968
5969 large_dialog(module_info_dlg);
5970
5971 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
5972 jwin_center_dialog(module_info_dlg);
5973
5974
5975 }
5976
5977 int32_t onAbout_ZCP_Module()
5978 {
5979 about_zcplayer_module("About Module (.zmod)", 0);
5980 return D_O_K;
5981 }
5982
5983 //New Modules Menu for 2.55+
5984 static MENU zcmodule_menu[] =
5985 {
5986 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
5987 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
5988
5989 { NULL, NULL, NULL, 0, NULL }
5990 };
5991
5992 int32_t onToggleRecordingNewSaves()
5993 {
5994 if (zc_get_config("zeldadx", "replay_new_saves", false))
5995 {
5996 zc_set_config("zeldadx", "replay_new_saves", false);
5997 }
5998 else
5999 {
6000 zc_set_config("zeldadx", "replay_new_saves", true);
6001 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6002 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6003 }
6004 return D_O_K;
6005 }
6006
6007 int32_t onToggleSnapshotAllFrames()
6008 {
6009 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6010 return D_O_K;
6011 }
6012
6013 int32_t onStopReplayOrRecord()
6014 {
6015 if (replay_is_replaying())
6016 {
6017 replay_quit();
6018 }
6019 else if (replay_get_mode() == ReplayMode::Record)
6020 {
6021 if (!replay_get_meta_bool("test_mode"))
6022 {
6023 jwin_alert("Recording", "You cannot stop recording a save file.",
6024 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6025 return D_CLOSE;
6026 }
6027
6028 if (jwin_alert("Stop Recording",
6029 "Save replay to disk and stop recording?",
6030 "This will stop the recording.",
6031 NULL,
6032 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6033 return D_CLOSE;
6034
6035 replay_save();
6036 replay_stop();
6037 }
6038 return D_O_K;
6039 }
6040
6041 static int32_t handle_on_load_replay(ReplayMode mode)
6042 {
6043 if (Playing)
6044 {
6045 if (jwin_alert("Replay - Warning!",
6046 "Loading a replay will exit the current game.",
6047 "All unsaved progress will be lost.",
6048 "Do you wish to continue?",
6049 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6050 return D_CLOSE;
6051 }
6052
6053 std::string mode_string = replay_mode_to_string(mode);
6054 mode_string[0] = std::toupper(mode_string[0]);
6055
6056 std::string line_1 = "Select a replay file to play back.";
6057 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6058 std::string line_3 = "You can stop the replay and take over manually any time.";
6059 if (mode == ReplayMode::Update)
6060 {
6061 line_1 = "Select a replay file to update.";
6062 line_2 = "WARNING: be sure to back up the zplay file";
6063 line_3 = "and verify that the updated replay works as expected!";
6064 }
6065
6066 if (jwin_alert(mode_string.c_str(),
6067 line_1.c_str(),
6068 line_2.c_str(),
6069 line_3.c_str(),
6070 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6071 {
6072 char replay_path[2048];
6073 strcpy(replay_path, "replays/");
6074 if (jwin_file_select_ex(
6075 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6076 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6077 return D_CLOSE;
6078
6079 replay_quit();
6080 load_replay_file_deferred(mode, replay_path);
6081 Quit = qRESET;
6082 return D_CLOSE;
6083 }
6084 return D_O_K;
6085 }
6086
6087 int32_t onLoadReplay()
6088 {
6089 return handle_on_load_replay(ReplayMode::Replay);
6090 }
6091
6092 int32_t onLoadReplayAssert()
6093 {
6094 return handle_on_load_replay(ReplayMode::Assert);
6095 }
6096
6097 int32_t onLoadReplayUpdate()
6098 {
6099 return handle_on_load_replay(ReplayMode::Update);
6100 }
6101
6102 int32_t onSaveReplay()
6103 {
6104 if (replay_get_mode() == ReplayMode::Record)
6105 {
6106 if (!replay_get_meta_bool("test_mode"))
6107 {
6108 if (jwin_alert("Save Replay",
6109 "This will save a copy of the replay up to this point.",
6110 "The official replay file will be untouched.",
6111 "Do you wish to continue?",
6112 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6113 return D_CLOSE;
6114
6115 char replay_path[2048];
6116 strcpy(replay_path, replay_get_replay_path().string().c_str());
6117 if (jwin_file_select_ex(
6118 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6119 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6120 return D_CLOSE;
6121
6122 if (fileexists(replay_path))
6123 {
6124 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6125 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6126 return D_CLOSE;
6127 }
6128
6129 replay_save(replay_path);
6130 }
6131 else
6132 {
6133 replay_save();
6134 }
6135 }
6136 return D_O_K;
6137 }
6138
6139 static MENU replay_menu[] =
6140 {
6141 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6142 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6143 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6144 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6145 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6146 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6147 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6148
6149 { NULL, NULL, NULL, 0, NULL }
6150 };
6151
6152 static DIALOG credits_dlg[] =
6153 {
6154 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6155 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6156 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6157 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6158 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6159 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6160 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6161 };
6162
6163 39 static ListData dmap_list(dmaplist, &font);
6164
6165 static DIALOG goto_dlg[] =
6166 {
6167 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6168 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6169 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6170 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6171 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6172 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6173 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6174 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6175 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6176 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6177 };
6178
6179 int32_t onGoTo()
6180 {
6181 bool music = false;
6182 music = music;
6183 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6184
6185 goto_dlg[0].dp2=get_zc_font(font_lfont);
6186 goto_dlg[4].d2=cheat_goto_dmap;
6187 goto_dlg[6].dp=cheat_goto_screen_str;
6188
6189 clear_keybuf();
6190
6191 large_dialog(goto_dlg);
6192
6193 if(zc_popup_dialog(goto_dlg,4)==1)
6194 {
6195 // dmap, screen
6196 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6197 };
6198
6199 return D_O_K;
6200 }
6201
6202 int32_t onGoToComplete()
6203 {
6204 if(!Playing)
6205 {
6206 return D_O_K;
6207 }
6208
6209 enter_sys_pal();
6210 music_pause();
6211 pause_all_sfx();
6212 onGoTo();
6213 eat_buttons();
6214
6215 zc_readrawkey(KEY_ESC);
6216
6217 exit_sys_pal();
6218 music_resume();
6219 resume_all_sfx();
6220 return D_O_K;
6221 }
6222
6223 int32_t onCredits()
6224 {
6225 go();
6226
6227 BITMAP *win = create_bitmap_ex(8,222,110);
6228
6229 if(!win)
6230 return D_O_K;
6231
6232 int32_t c=0;
6233 int32_t l=0;
6234 int32_t ol=-1;
6235 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6236 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6237 PALETTE tmppal;
6238
6239 rti_gui.transparency_index = 1;
6240
6241 clear_to_color(win, rti_gui.transparency_index);
6242 draw_rle_sprite(win,rle,0,0);
6243 credits_dlg[0].dp2=get_zc_font(font_lfont);
6244 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6245 credits_dlg[2].dp = win;
6246
6247 zc_set_palette_range(black_palette,0,127,false);
6248
6249 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6250
6251 BITMAP* old_screen = screen;
6252 BITMAP* gui_bmp = zc_get_gui_bmp();
6253 ASSERT(gui_bmp);
6254 clear_to_color(gui_bmp, rti_gui.transparency_index);
6255 screen = gui_bmp;
6256
6257 while(update_dialog(p))
6258 {
6259 throttleFPS();
6260 ++c;
6261 l = zc_max((c>>1)-30,0);
6262
6263 if(l > rle->h)
6264 l = c = 0;
6265
6266 if(l > rle->h - 112)
6267 l = rle->h - 112;
6268
6269 clear_bitmap(win);
6270 draw_rle_sprite(win,rle,0,0-l);
6271
6272 if(c<=64)
6273 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6274
6275 zc_set_palette_range(tmppal,0,127,false);
6276
6277 if(l!=ol)
6278 {
6279 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6280 SCRFIX();
6281 ol=l;
6282 }
6283
6284 update_hw_screen();
6285 }
6286
6287 screen = old_screen;
6288 system_pal(true);
6289 sys_mouse();
6290
6291 shutdown_dialog(p);
6292 destroy_bitmap(win);
6293 //comeback();
6294
6295 rti_gui.transparency_index = 0;
6296 clear_to_color(gui_bmp, rti_gui.transparency_index);
6297
6298 return D_O_K;
6299 }
6300
6301 const char *midilist(int32_t index, int32_t *list_size)
6302 {
6303 if(index<0)
6304 {
6305 *list_size=0;
6306
6307 for(int32_t i=0; i<MAXMIDIS; i++)
6308 if(tunes[i].data)
6309 ++(*list_size);
6310
6311 return NULL;
6312 }
6313
6314 int32_t i=0,m=0;
6315
6316 while(m<=index && i<=MAXMIDIS)
6317 {
6318 if(tunes[i].data)
6319 ++m;
6320
6321 ++i;
6322 }
6323
6324 --i;
6325
6326 if(i==MAXMIDIS && m<index)
6327 return "(null)";
6328
6329 return tunes[i].title;
6330 }
6331
6332 /* ------- MIDI info stuff -------- */
6333
6334 char *text;
6335 midi_info *zmi;
6336 bool dialog_running;
6337 bool listening;
6338
6339 void get_info(int32_t index);
6340
6341 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6342 {
6343 int32_t d2 = d->d2;
6344 int32_t ret = jwin_droplist_proc(msg,d,c);
6345
6346 if(d2!=d->d2)
6347 {
6348 get_info(d->d2);
6349 }
6350
6351 return ret;
6352 }
6353
6354 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6355 {
6356 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6357
6358 int32_t ret = jwin_button_proc(msg,d,c);
6359
6360 if(ret == D_CLOSE)
6361 {
6362 // get current midi index
6363 int32_t index = (d+(d->d1))->d2;
6364 int32_t i=0, m=0;
6365
6366 while(m<=index && i<=MAXMIDIS)
6367 {
6368 if(tunes[i].data)
6369 ++m;
6370
6371 ++i;
6372 }
6373
6374 --i;
6375 jukebox(i);
6376 listening = true;
6377 ret = D_O_K;
6378 }
6379
6380 return ret;
6381 }
6382
6383 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6384 {
6385 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6386
6387 int32_t ret = jwin_button_proc(msg,d,c);
6388
6389 if(ret == D_CLOSE)
6390 {
6391 // get current midi index
6392 int32_t index = (d+(d->d1))->d2;
6393 int32_t i=0, m=0;
6394
6395 while(m<=index && i<=MAXMIDIS)
6396 {
6397 if(tunes[i].data)
6398 ++m;
6399
6400 ++i;
6401 }
6402
6403 --i;
6404
6405 // get file name
6406
6407 int32_t sel=0;
6408 //struct ffblk f;
6409 char title[40] = "Save MIDI: ";
6410 char fname[2048];
6411 memset(fname,0,2048);
6412 static EXT_LIST list[] =
6413 {
6414 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6415 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6416 { NULL, NULL }
6417 };
6418
6419 strcpy(title+11, tunes[i].title);
6420 title[39] = '\0';
6421
6422 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6423 goto done;
6424
6425 if(exists(fname))
6426 {
6427 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6428 goto done;
6429 }
6430
6431 // save midi i
6432
6433 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6434 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6435
6436 done:
6437 chop_path(fname);
6438 ret = D_REDRAW;
6439 }
6440
6441 return ret;
6442 }
6443
6444 39 static ListData midi_list(midilist, &font);
6445
6446 static DIALOG midi_dlg[] =
6447 {
6448 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6449 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6450 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6451 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6452 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6453 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6454 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6455 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6456 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6457 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6458 };
6459
6460 void get_info(int32_t index)
6461 {
6462 int32_t i=0, m=0;
6463
6464 while(m<=index && i<=MAXMIDIS)
6465 {
6466 if(tunes[i].data)
6467 ++m;
6468
6469 ++i;
6470 }
6471
6472 --i;
6473
6474 if(i==MAXMIDIS && m<index)
6475 strcpy(text,"(null)");
6476 else
6477 {
6478 get_midi_info((MIDI*)tunes[i].data,zmi);
6479 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6480 }
6481
6482 midi_dlg[0].dp2=get_zc_font(font_lfont);
6483 midi_dlg[3].dp = text;
6484 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6485 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6486
6487 if(dialog_running)
6488 {
6489 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6490 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6491 }
6492 }
6493
6494 int32_t onMIDICredits()
6495 {
6496 text = (char*)malloc(4096);
6497 zmi = (midi_info*)malloc(sizeof(midi_info));
6498
6499 if(!text || !zmi)
6500 {
6501 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6502 return D_O_K;
6503 }
6504
6505 bool do_pause_midi = midi_pos >= 0 && currmidi;
6506 auto restore_midi = currmidi;
6507 if(do_pause_midi)
6508 {
6509 paused_midi_pos = midi_pos;
6510 stop_midi();
6511 midi_paused=true;
6512 midi_suspended = midissuspHALTED;
6513 }
6514
6515 midi_dlg[0].dp2=get_zc_font(font_lfont);
6516 midi_dlg[2].d1 = 0;
6517 midi_dlg[2].d2 = 0;
6518 midi_dlg[4].flags = D_EXIT;
6519 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6520
6521 listening = false;
6522 dialog_running=false;
6523 get_info(0);
6524
6525 dialog_running=true;
6526
6527 large_dialog(midi_dlg);
6528
6529 zc_popup_dialog(midi_dlg,0);
6530 dialog_running=false;
6531
6532 if(listening)
6533 music_stop();
6534
6535 if(do_pause_midi)
6536 {
6537 midi_suspended = midissuspRESUME;
6538 currmidi = restore_midi;
6539 midi_pos = paused_midi_pos;
6540 }
6541
6542 if(text) free(text);
6543 if(zmi) free(zmi);
6544 return D_O_K;
6545 }
6546
6547 int32_t onAbout()
6548 {
6549 char buf1[80]={0};
6550 std::ostringstream oss;
6551 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6552 oss << buf1 << '\n';
6553 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6554 oss << buf1 << '\n';
6555 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6556 oss << buf1 << '\n';
6557 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6558 oss << buf1 << '\n';
6559 sprintf(buf1, "Tag: %s", getReleaseTag());
6560 oss << buf1 << '\n';
6561
6562 InfoDialog("About ZC", oss.str()).show();
6563 return D_O_K;
6564 }
6565
6566 int32_t onQuest()
6567 {
6568 char fname[100];
6569 strcpy(fname, get_filename(qstpath));
6570 quest_dlg[0].dp2=get_zc_font(font_lfont);
6571 quest_dlg[1].dp = fname;
6572
6573 if(QHeader.quest_number==0)
6574 sprintf(str_a,"Custom");
6575 else
6576 sprintf(str_a,"%d",QHeader.quest_number);
6577
6578 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6579
6580 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6581 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6582
6583 large_dialog(quest_dlg);
6584
6585 zc_popup_dialog(quest_dlg, 0);
6586 return D_O_K;
6587 }
6588
6589 void call_vidmode_dlg();
6590 int32_t onVidMode()
6591 {
6592 call_vidmode_dlg();
6593 return D_O_K;
6594 }
6595
6596 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6597 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6598 //Added an extra statement, so that if the key is cleared to 0, the cleared
6599 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6600
6601 void load_ukeys(int32_t* arr)
6602 {
6603 arr[ukey_a] = Akey;
6604 arr[ukey_b] = Bkey;
6605 arr[ukey_s] = Skey;
6606 arr[ukey_l] = Lkey;
6607 arr[ukey_r] = Rkey;
6608 arr[ukey_p] = Pkey;
6609 arr[ukey_ex1] = Exkey1;
6610 arr[ukey_ex2] = Exkey2;
6611 arr[ukey_ex3] = Exkey3;
6612 arr[ukey_ex4] = Exkey4;
6613 arr[ukey_du] = DUkey;
6614 arr[ukey_dd] = DDkey;
6615 arr[ukey_dl] = DLkey;
6616 arr[ukey_dr] = DRkey;
6617 arr[ukey_mod1a] = cheat_modifier_keys[0];
6618 arr[ukey_mod1b] = cheat_modifier_keys[1];
6619 arr[ukey_mod2a] = cheat_modifier_keys[2];
6620 arr[ukey_mod2b] = cheat_modifier_keys[3];
6621 };
6622
6623 static const char* ukey_names[] = {
6624 "A", "B", "Start", "L", "R", "Map",
6625 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6626 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6627 "Cheat Mod R1", "Cheat Mod R2",
6628 };
6629 std::string get_ukey_name(int32_t k)
6630 {
6631 if (k < num_ukey) return ukey_names[k];
6632 return "";
6633 }
6634
6635 int32_t onKeyboard()
6636 {
6637 int32_t a = Akey;
6638 int32_t b = Bkey;
6639 int32_t s = Skey;
6640 int32_t l = Lkey;
6641 int32_t r = Rkey;
6642 int32_t p = Pkey;
6643 int32_t ex1 = Exkey1;
6644 int32_t ex2 = Exkey2;
6645 int32_t ex3 = Exkey3;
6646 int32_t ex4 = Exkey4;
6647 int32_t du = DUkey;
6648 int32_t dd = DDkey;
6649 int32_t dl = DLkey;
6650 int32_t dr = DRkey;
6651 int32_t mod1a = cheat_modifier_keys[0];
6652 int32_t mod1b = cheat_modifier_keys[1];
6653 int32_t mod2a = cheat_modifier_keys[2];
6654 int32_t mod2b = cheat_modifier_keys[3];
6655 bool done=false;
6656 int32_t ret;
6657
6658 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6659
6660 large_dialog(keyboard_control_dlg);
6661
6662 while(!done)
6663 {
6664 ret = zc_popup_dialog(keyboard_control_dlg,3);
6665
6666 if(ret==3) // OK
6667 {
6668 int32_t ukeys[num_ukey];
6669 load_ukeys(ukeys);
6670 std::vector<std::string> uniqueError;
6671 for(int32_t q = 0; q < num_ukey; ++q)
6672 {
6673 for(int32_t p = q+1; p < num_ukey; ++p)
6674 {
6675 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6676 {
6677 char buf[64];
6678 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6679 std::string str(buf);
6680 uniqueError.push_back(str);
6681 }
6682 }
6683 }
6684 if(uniqueError.size() == 0)
6685 {
6686 done = true;
6687 save_control_configs(true);
6688 }
6689 else
6690 {
6691 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6692 box_out("Cannot have duplicate keybinds!"); box_eol();
6693 for(std::vector<std::string>::iterator it = uniqueError.begin();
6694 it != uniqueError.end(); ++it)
6695 {
6696 box_out((*it).c_str()); box_eol();
6697 }
6698 box_end(true);
6699 }
6700 }
6701 else // Cancel
6702 {
6703 Akey = a;
6704 Bkey = b;
6705 Skey = s;
6706 Lkey = l;
6707 Rkey = r;
6708 Pkey = p;
6709 Exkey1 = ex1;
6710 Exkey2 = ex2;
6711 Exkey3 = ex3;
6712 Exkey4 = ex4;
6713 DUkey = du;
6714 DDkey = dd;
6715 DLkey = dl;
6716 DRkey = dr;
6717 cheat_modifier_keys[0] = mod1a;
6718 cheat_modifier_keys[1] = mod1b;
6719 cheat_modifier_keys[2] = mod2a;
6720 cheat_modifier_keys[3] = mod2b;
6721
6722 done=true;
6723 }
6724
6725 rest(1);
6726 }
6727
6728 return D_O_K;
6729 }
6730
6731 int32_t onGamepad()
6732 {
6733 int32_t a = Abtn;
6734 int32_t b = Bbtn;
6735 int32_t s = Sbtn;
6736 int32_t l = Lbtn;
6737 int32_t r = Rbtn;
6738 int32_t m = Mbtn;
6739 int32_t p = Pbtn;
6740 int32_t ex1 = Exbtn1;
6741 int32_t ex2 = Exbtn2;
6742 int32_t ex3 = Exbtn3;
6743 int32_t ex4 = Exbtn4;
6744 int32_t up = DUbtn;
6745 int32_t down = DDbtn;
6746 int32_t left = DLbtn;
6747 int32_t right = DRbtn;
6748
6749 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6750 if(analog_movement)
6751 gamepad_dlg[56].flags|=D_SELECTED;
6752 else
6753 gamepad_dlg[56].flags&=~D_SELECTED;
6754
6755 large_dialog(gamepad_dlg);
6756
6757 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6758
6759 if(ret == 4) //OK
6760 {
6761 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6762 save_control_configs(false);
6763 }
6764 else //Cancel
6765 {
6766 Abtn = a;
6767 Bbtn = b;
6768 Sbtn = s;
6769 Lbtn = l;
6770 Rbtn = r;
6771 Mbtn = m;
6772 Pbtn = p;
6773 Exbtn1 = ex1;
6774 Exbtn2 = ex2;
6775 Exbtn3 = ex3;
6776 Exbtn4 = ex4;
6777 DUbtn = up;
6778 DDbtn = down;
6779 DLbtn = left;
6780 DRbtn = right;
6781 }
6782
6783 return D_O_K;
6784 }
6785
6786 int32_t onCheatKeys()
6787 {
6788 int32_t oldcheats[Cheat::Last][2];
6789 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6790
6791 bool done=false;
6792
6793 while(!done)
6794 {
6795 bool confirm = false;
6796 CheatKeysDialog(&confirm).show();
6797 if(confirm) // OK
6798 {
6799 std::vector<std::string> uniqueError;
6800 char buf[512];
6801 for(size_t q = 1; q < Cheat::Last; ++q)
6802 {
6803 if(cheatkeys[q][1] && !cheatkeys[q][0])
6804 {
6805 cheatkeys[q][0] = cheatkeys[q][1];
6806 cheatkeys[q][1] = 0;
6807 }
6808 }
6809 for(size_t q = 1; q < Cheat::Last; ++q)
6810 {
6811 if(!bindable_cheat((Cheat)q)) continue;
6812 for(size_t p = q+1; p < Cheat::Last; ++p)
6813 {
6814 if(!bindable_cheat((Cheat)p)) continue;
6815 for(size_t q2 = 0; q2 <= 1; ++q2)
6816 for(size_t p2 = 0; p2 <= 1; ++p2)
6817 {
6818 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6819 {
6820 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6821 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6822 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6823 get_keystr(cheatkeys[q][q2])));
6824 }
6825 }
6826 }
6827 }
6828 if(uniqueError.size() == 0)
6829 {
6830 done = true;
6831 save_cheatkeys();
6832 }
6833 else
6834 {
6835 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6836 box_out("Cannot have duplicate keybinds!"); box_eol();
6837 for(std::vector<std::string>::iterator it = uniqueError.begin();
6838 it != uniqueError.end(); ++it)
6839 {
6840 box_out((*it).c_str()); box_eol();
6841 }
6842 box_end(true);
6843 }
6844 }
6845 else // Cancel
6846 {
6847 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6848 done=true;
6849 }
6850 rest(1);
6851 }
6852
6853 return D_O_K;
6854 }
6855
6856 int32_t onSound()
6857 {
6858 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6859 {
6860 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6861 }
6862 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6863 {
6864 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6865 }
6866 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6867 {
6868 emusic_volume = (int32_t)FFCore.usr_music_volume;
6869 }
6870 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
6871 {
6872 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6873 }
6874 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6875 {
6876 pan_style = (int32_t)FFCore.usr_panstyle;
6877 }
6878
6879 int32_t m = midi_volume;
6880 int32_t d = digi_volume;
6881 int32_t e = emusic_volume;
6882 int32_t b = zcmusic_bufsz;
6883 int32_t s = sfx_volume;
6884 int32_t p = pan_style;
6885 pan_style = vbound(pan_style,0,3);
6886
6887 sound_dlg[0].dp2=get_zc_font(font_lfont);
6888
6889 large_dialog(sound_dlg);
6890
6891 midi_dp[1] = sound_dlg[6].x;
6892 midi_dp[2] = sound_dlg[6].y;
6893 digi_dp[1] = sound_dlg[7].x;
6894 digi_dp[2] = sound_dlg[7].y;
6895 emus_dp[1] = sound_dlg[8].x;
6896 emus_dp[2] = sound_dlg[8].y;
6897 buf_dp[1] = sound_dlg[9].x;
6898 buf_dp[2] = sound_dlg[9].y;
6899 sfx_dp[1] = sound_dlg[10].x;
6900 sfx_dp[2] = sound_dlg[10].y;
6901 pan_dp[1] = sound_dlg[11].x;
6902 pan_dp[2] = sound_dlg[11].y;
6903 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6904 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6905 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6906 sound_dlg[18].d2 = zcmusic_bufsz;
6907 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6908 sound_dlg[20].d2 = pan_style;
6909
6910 int32_t ret = zc_popup_dialog(sound_dlg,1);
6911
6912 if(ret==2)
6913 {
6914 master_volume(digi_volume,midi_volume);
6915
6916 for(int32_t i=0; i<WAV_COUNT; ++i)
6917 {
6918 //allegro assertion fails when passing in -1 as voice -DD
6919 if(sfx_voice[i] > 0)
6920 voice_set_volume(sfx_voice[i], sfx_volume);
6921 }
6922 zc_set_config(sfx_sect,"digi",digi_volume);
6923 zc_set_config(sfx_sect,"midi",midi_volume);
6924 zc_set_config(sfx_sect,"sfx",sfx_volume);
6925 zc_set_config(sfx_sect,"emusic",emusic_volume);
6926 zc_set_config(sfx_sect,"pan",pan_style);
6927 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6928 }
6929 else
6930 {
6931 midi_volume = m;
6932 digi_volume = d;
6933 emusic_volume = e;
6934 zcmusic_bufsz = b;
6935 sfx_volume = s;
6936 pan_style = p;
6937 }
6938
6939 return D_O_K;
6940 }
6941
6942 int32_t queding(char const* s1, char const* s2, char const* s3)
6943 {
6944 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6945 }
6946
6947 int32_t onQuit()
6948 {
6949 if(Playing)
6950 {
6951 int32_t ret=0;
6952
6953 if(get_bit(quest_rules, qr_NOCONTINUE))
6954 {
6955 if(standalone_mode)
6956 {
6957 ret=queding("End current game?",
6958 "The continue screen is disabled; the game",
6959 "will be reloaded from the last save.");
6960 }
6961 else
6962 {
6963 ret=queding("End current game?",
6964 "The continue screen is disabled. You will",
6965 "be returned to the file select screen.");
6966 }
6967 }
6968 else
6969 ret=queding("End current game?",NULL,NULL);
6970
6971 if(ret==1)
6972 {
6973 disableClickToFreeze=false;
6974 Quit=qQUIT;
6975
6976 // Trying to evade a door repair charge?
6977 if(repaircharge)
6978 {
6979 game->change_drupy(-repaircharge);
6980 repaircharge=0;
6981 }
6982
6983 return D_CLOSE;
6984 }
6985 }
6986
6987 return D_O_K;
6988 }
6989
6990 int32_t onTryQuitMenu()
6991 {
6992 return onTryQuit(true);
6993 }
6994
6995 int32_t onTryQuit(bool inMenu)
6996 {
6997 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
6998 {
6999 if(active_cutscene.can_f6())
7000 {
7001 if(get_bit(quest_rules,qr_OLD_F6))
7002 {
7003 if(inMenu) onQuit();
7004 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7005 }
7006 else
7007 {
7008 disableClickToFreeze=false;
7009 GameFlags |= GAMEFLAG_TRYQUIT;
7010 }
7011 return D_CLOSE;
7012 }
7013 else active_cutscene.error();
7014 }
7015
7016 return D_O_K;
7017 }
7018
7019 int32_t onReset()
7020 {
7021 if(queding(" Reset system? ",NULL,NULL)==1)
7022 {
7023 disableClickToFreeze=false;
7024 Quit=qRESET;
7025 replay_quit();
7026 return D_CLOSE;
7027 }
7028
7029 return D_O_K;
7030 }
7031
7032 int32_t onExit()
7033 {
7034 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7035 {
7036 Quit=qEXIT;
7037 return D_CLOSE;
7038 }
7039
7040 return D_O_K;
7041 }
7042
7043 int32_t onTitle_NES()
7044 {
7045 title_version=0;
7046 zc_set_config(cfg_sect,"title",title_version);
7047 return D_O_K;
7048 }
7049 int32_t onTitle_DX()
7050 {
7051 title_version=1;
7052 zc_set_config(cfg_sect,"title",title_version);
7053 return D_O_K;
7054 }
7055 int32_t onTitle_25()
7056 {
7057 title_version=2;
7058 zc_set_config(cfg_sect,"title",title_version);
7059 return D_O_K;
7060 }
7061
7062 int32_t onDebug()
7063 {
7064 if(debug_enabled)
7065 set_debug(!get_debug());
7066 return D_O_K;
7067 }
7068
7069 int32_t onHeartBeep()
7070 {
7071 heart_beep=!heart_beep;
7072 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7073 return D_O_K;
7074 }
7075
7076 int32_t onSaveIndicator()
7077 {
7078 use_save_indicator = use_save_indicator ? 0 : 1;
7079 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7080 return D_O_K;
7081 }
7082
7083 int32_t onEpilepsy()
7084 {
7085 if(jwin_alert3(
7086 "Epilepsy Flash Reduction",
7087 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7088 "Disabling this will restore standard flash and wavy behaviour.",
7089 "Proceed?",
7090 "&Yes",
7091 "&No",
7092 NULL,
7093 'y',
7094 'n',
7095 0,
7096 get_zc_font(font_lfont)) == 1)
7097 {
7098 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7099 zc_set_config("zeldadx","checked_epilepsy",1);
7100 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7101 }
7102 return D_O_K;
7103 }
7104
7105 int32_t onTriforce()
7106 {
7107 for(int32_t i=0; i<MAXINITTABS; ++i)
7108 {
7109 init_tabs[i].flags&=~D_SELECTED;
7110 }
7111
7112 init_tabs[3].flags=D_SELECTED;
7113 return onCheatConsole();
7114 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7115 for(int32_t i=1; i<=8; i++)
7116 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7117
7118 if(zc_popup_dialog (triforce_dlg,-1)==9)
7119 {
7120 for(int32_t i=1; i<=8; i++)
7121 {
7122 game->lvlitems[i] &= ~liTRIFORCE;
7123 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7124 }
7125 }
7126 return D_O_K;*/
7127 }
7128
7129 bool rc = false;
7130 /*
7131 int32_t onEquipment()
7132 {
7133 for (int32_t i=0; i<MAXINITTABS; ++i)
7134 {
7135 init_tabs[i].flags&=~D_SELECTED;
7136 }
7137 init_tabs[0].flags=D_SELECTED;
7138 return onCheatConsole();
7139 }
7140 */
7141
7142 int32_t onItems()
7143 {
7144 for(int32_t i=0; i<MAXINITTABS; ++i)
7145 {
7146 init_tabs[i].flags&=~D_SELECTED;
7147 }
7148
7149 init_tabs[1].flags=D_SELECTED;
7150 return onCheatConsole();
7151 }
7152
7153 static DIALOG getnum_dlg[] =
7154 {
7155 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7156 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7157 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7158 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7159 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7160 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7161 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7162 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7163 };
7164
7165 int32_t getnumber(const char *prompt,int32_t initialval)
7166 {
7167 char buf[20];
7168 sprintf(buf,"%d",initialval);
7169 getnum_dlg[0].dp=(void *)prompt;
7170 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7171 getnum_dlg[2].dp=buf;
7172
7173 large_dialog(getnum_dlg);
7174
7175 if(zc_popup_dialog(getnum_dlg,2)==3)
7176 return atoi(buf);
7177
7178 return initialval;
7179 }
7180
7181 int32_t onLife()
7182 {
7183 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7184 cheats_enqueue(Cheat::Life, value);
7185 return D_O_K;
7186 }
7187
7188 int32_t onHeartC()
7189 {
7190 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7191 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7192 cheats_enqueue(Cheat::MaxLife, max_life);
7193 cheats_enqueue(Cheat::Life, life);
7194 return D_O_K;
7195 }
7196
7197 int32_t onMagicC()
7198 {
7199 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7200 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7201 cheats_enqueue(Cheat::MaxMagic, max_magic);
7202 cheats_enqueue(Cheat::Magic, magic);
7203 return D_O_K;
7204 }
7205
7206 int32_t onRupies()
7207 {
7208 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7209 cheats_enqueue(Cheat::Rupies, value);
7210 return D_O_K;
7211 }
7212
7213 int32_t onMaxBombs()
7214 {
7215 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7216 cheats_enqueue(Cheat::MaxBombs, value);
7217 cheats_enqueue(Cheat::Bombs, value);
7218 return D_O_K;
7219 }
7220
7221 int32_t onRefillLife()
7222 {
7223 cheats_enqueue(Cheat::Life, game->get_maxlife());
7224 return D_O_K;
7225 }
7226 int32_t onRefillMagic()
7227 {
7228 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7229 return D_O_K;
7230 }
7231 int32_t onClock()
7232 {
7233 cheats_enqueue(Cheat::Clock);
7234 return D_O_K;
7235 }
7236
7237 int32_t onQstPath()
7238 {
7239 char path[2048];
7240
7241 chop_path(qstdir);
7242 strcpy(path,qstdir);
7243
7244 go();
7245
7246 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7247 {
7248 chop_path(path);
7249 fix_filename_case(path);
7250 fix_filename_slashes(path);
7251 strcpy(qstdir,path);
7252 strcpy(qstpath,qstdir);
7253 }
7254
7255 comeback();
7256 return D_O_K;
7257 }
7258
7259 #include "dialog/cheat_dialog.h"
7260 int32_t onCheat()
7261 {
7262 call_setcheat_dialog();
7263 game->set_cheat(maxcheat);
7264 if(cheat) game->did_cheat(true);
7265 return D_O_K;
7266 }
7267
7268 int32_t onCheatRupies()
7269 {
7270 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7271 return D_O_K;
7272 }
7273
7274 int32_t onCheatArrows()
7275 {
7276 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7277 return D_O_K;
7278 }
7279
7280 int32_t onCheatBombs()
7281 {
7282 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7283 return D_O_K;
7284 }
7285
7286 // *** screen saver
7287
7288 8116819 int32_t after_time()
7289 {
7290
1/2
✓ Branch 0 taken 8116819 times.
✗ Branch 1 not taken.
8116819 if(ss_enable == 0)
7291 return INT_MAX;
7292
7293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116819 times.
8116819 if(ss_after <= 0)
7294 return 5 * 60;
7295
7296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116819 times.
8116819 if(ss_after <= 3)
7297 return ss_after * 15 * 60;
7298
7299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116819 times.
8116819 if(ss_after <= 13)
7300 return (ss_after - 3) * 60 * 60;
7301
7302 8116819 return MAX_IDLE + 1;
7303 8116819 }
7304
7305 static const char *after_str[15] =
7306 {
7307 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7308 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7309 "Never"
7310 };
7311
7312 const char *after_list(int32_t index, int32_t *list_size)
7313 {
7314 if(index < 0)
7315 {
7316 *list_size = 15;
7317 return NULL;
7318 }
7319
7320 return after_str[index];
7321 }
7322
7323 39 static ListData after__list(after_list, &font);
7324
7325 static DIALOG scrsaver_dlg[] =
7326 {
7327 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7328 39 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7329 39 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7330 39 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7331 39 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7332 39 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7333 39 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7334 39 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7335 39 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7336 39 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7337 39 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7338 39 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7339 39 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7340 39 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7341 };
7342
7343 int32_t onScreenSaver()
7344 {
7345 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7346 int32_t oldcfgs[3];
7347 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7348 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7349 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7350
7351 large_dialog(scrsaver_dlg);
7352
7353 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7354
7355 if(ret == 8 || ret == 9)
7356 {
7357 ss_after = scrsaver_dlg[5].d1;
7358 ss_speed = scrsaver_dlg[6].d2;
7359 ss_density = scrsaver_dlg[7].d2;
7360 if(oldcfgs[0] != ss_after)
7361 zc_set_config(cfg_sect,"ss_after",ss_after);
7362 if(oldcfgs[1] != ss_speed)
7363 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7364 if(oldcfgs[2] != ss_density)
7365 zc_set_config(cfg_sect,"ss_density",ss_density);
7366 }
7367
7368 if(ret == 9)
7369 // preview Screen Saver
7370 {
7371 clear_keybuf();
7372 Matrix(ss_speed, ss_density, 30);
7373 system_pal();
7374 sys_mouse();
7375 }
7376
7377 return D_O_K;
7378 }
7379
7380 /***** Menus *****/
7381
7382 static MENU game_menu[] =
7383 {
7384 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7385 { (char *)"", NULL, NULL, 0, NULL },
7386 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7387 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7388 { (char *)"", NULL, NULL, 0, NULL },
7389 #ifdef __EMSCRIPTEN__
7390 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7391 #elif defined(ALLEGRO_MACOSX)
7392 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7393 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7394 #else
7395 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7396 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7397 #endif
7398 { NULL, NULL, NULL, 0, NULL }
7399 };
7400
7401 static MENU title_menu[] =
7402 {
7403 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7404 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7405 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7406 { NULL, NULL, NULL, 0, NULL }
7407 };
7408
7409 static MENU snapshot_format_menu[] =
7410 {
7411 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7412 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7413 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7414 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7415 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7416 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7417 { NULL, NULL, NULL, 0, NULL }
7418 };
7419
7420 static MENU controls_menu[] =
7421 {
7422 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7423 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7424 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7425 { NULL, NULL, NULL, 0, NULL }
7426 };
7427
7428 static MENU name_entry_mode_menu[] =
7429 {
7430 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7431 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7432 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7433 { NULL, NULL, NULL, 0, NULL }
7434 };
7435
7436 static void set_controls_menu_active()
7437 {
7438
7439 }
7440
7441 static MENU window_menu[] =
7442 {
7443 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7444 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7445 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7446 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7447 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7448 { NULL, NULL, NULL, 0, NULL }
7449 };
7450 static MENU options_menu[] =
7451 {
7452 { "&Title Screen", NULL, title_menu, 0, NULL },
7453 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7454 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7455 { "&Window Settings", NULL, window_menu, 0, NULL },
7456 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7457 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7458 { NULL, NULL, NULL, 0, NULL }
7459 };
7460 static MENU settings_menu[] =
7461 {
7462 { "&Sound...", onSound, NULL, 0, NULL },
7463 { "C&ontrols", NULL, controls_menu, 0, NULL },
7464 { "", NULL, NULL, 0, NULL },
7465 { "Options", NULL, options_menu, 0, NULL },
7466 { "", NULL, NULL, 0, NULL },
7467 //
7468 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7469 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7470 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7471 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7472 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7473 //
7474 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7475 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7476 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7477 { "", NULL, NULL, 0, NULL },
7478 { "Debu&g", onDebug, NULL, 0, NULL },
7479 //
7480 { NULL, NULL, NULL, 0, NULL }
7481 };
7482
7483
7484 static MENU misc_menu[] =
7485 {
7486 { (char *)"&About...", onAbout, NULL, 0, NULL },
7487 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7488 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7489 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7490 { (char *)"", NULL, NULL, 0, NULL },
7491 //5
7492 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7493 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7494 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7495 { (char *)"", NULL, NULL, 0, NULL },
7496 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7497 //10
7498 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7499 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7500 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7501 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7502 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7503 //15
7504 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7505 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7506 { NULL, NULL, NULL, 0, NULL }
7507 };
7508
7509 static MENU refill_menu[] =
7510 {
7511 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7512 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7513 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7514 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7515 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7516 { NULL, NULL, NULL, 0, NULL }
7517 };
7518
7519 static MENU show_menu[] =
7520 {
7521 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7522 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7523 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7524 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7525 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7526 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7527 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7528 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7529 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7530 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7531 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7532 { (char *)"", NULL, NULL, 0, NULL },
7533 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7534 { (char *)"", NULL, NULL, 0, NULL },
7535 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7536 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7537 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7538 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7539 { NULL, NULL, NULL, 0, NULL }
7540 };
7541
7542 static MENU cheat_menu[] =
7543 {
7544 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7545 { (char *)"", NULL, NULL, 0, NULL },
7546 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7547 { (char *)"", NULL, NULL, 0, NULL },
7548 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7549 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7550 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7551 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7552 { (char *)"", NULL, NULL, 0, NULL },
7553 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7554 { (char *)"", NULL, NULL, 0, NULL },
7555 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7556 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7557 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7558 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7559 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7560 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7561 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7562 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7563 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7564 { NULL, NULL, NULL, 0, NULL }
7565 };
7566
7567 #if DEVLEVEL > 0
7568 int32_t devLogging();
7569 int32_t devDebug();
7570 int32_t devTimestmp();
7571 #if DEVLEVEL > 1
7572 int32_t setCheat();
7573 #endif //DEVLEVEL > 1
7574 enum
7575 {
7576 dv_log,
7577 // dv_dbg,
7578 dv_tmpstmp,
7579 #if DEVLEVEL > 1
7580 dv_nil,
7581 dv_setcheat,
7582 #endif //DEVLEVEL > 1
7583 dv_max
7584 };
7585 static MENU dev_menu[] =
7586 {
7587 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7588 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7589 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7590 #if DEVLEVEL > 1
7591 { (char *)"", NULL, NULL, 0, NULL },
7592 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7593 #endif //DEVLEVEL > 1
7594 { NULL, NULL, NULL, 0, NULL }
7595 };
7596 int32_t devLogging()
7597 {
7598 dev_logging = !dev_logging;
7599 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7600 return D_O_K;
7601 }
7602 // int32_t devDebug()
7603 // {
7604 // dev_debug = !dev_debug;
7605 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7606 // return D_O_K;
7607 // }
7608 int32_t devTimestmp()
7609 {
7610 dev_timestmp = !dev_timestmp;
7611 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7612 return D_O_K;
7613 }
7614 #if DEVLEVEL > 1
7615 int32_t setCheat()
7616 {
7617 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7618 return D_O_K;
7619 }
7620 #endif //DEVLEVEL > 1
7621 #endif //DEVLEVEL > 0
7622
7623 MENU the_player_menu[] =
7624 {
7625 { (char *)"&Game", NULL, game_menu, 0, NULL },
7626 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7627 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7628 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7629 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7630 #if DEVLEVEL > 0
7631 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7632 #endif
7633 { NULL, NULL, NULL, 0, NULL }
7634 };
7635 int32_t onMIDIPatch()
7636 {
7637 if(jwin_alert3(
7638 "Toggle Windows MIDI Fix",
7639 "This action will change whether ZC Player auto-restarts a MIDI at its",
7640 "last index if you move ZC Player out of focus, then back into focus.",
7641 "Proceed?",
7642 "&Yes",
7643 "&No",
7644 NULL,
7645 'y',
7646 'n',
7647 0,
7648 get_zc_font(font_lfont)) == 1)
7649 {
7650 midi_patch_fix = midi_patch_fix ? 0 : 1;
7651 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7652 }
7653 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7654 return D_O_K;
7655 }
7656
7657 int32_t onKeyboardEntry()
7658 {
7659 NameEntryMode=0;
7660 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7661 return D_O_K;
7662 }
7663
7664 int32_t onLetterGridEntry()
7665 {
7666 NameEntryMode=1;
7667 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7668 return D_O_K;
7669 }
7670
7671 int32_t onExtLetterGridEntry()
7672 {
7673 NameEntryMode=2;
7674 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7675 return D_O_K;
7676 }
7677
7678 static BITMAP* oldscreen;
7679 int32_t onFullscreenMenu()
7680 {
7681 // super hacks
7682 screen = oldscreen;
7683 if (onFullscreen() == D_REDRAW)
7684 {
7685 oldscreen = screen;
7686 }
7687 screen = menu_bmp;
7688 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7689 return D_O_K;
7690 }
7691
7692 39 void fix_menu()
7693 {
7694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(!debug_enabled)
7695 39 settings_menu[13].text = NULL;
7696 39 }
7697
7698 static DIALOG system_dlg[] =
7699 {
7700 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7701 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7702 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7703 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7704 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7705 #ifndef ALLEGRO_MACOSX
7706 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7707 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7708 #else
7709 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7710 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7711 #endif
7712 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7713 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7714 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7715 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7716 };
7717
7718 void reset_snapshot_format_menu()
7719 {
7720 for(int32_t i=0; i<ssfmtMAX; ++i)
7721 {
7722 snapshot_format_menu[i].flags=0;
7723 }
7724 }
7725
7726 int32_t onSetSnapshotFormat()
7727 {
7728 switch(active_menu->text[1])
7729 {
7730 case 'B': //"&BMP"
7731 SnapshotFormat=0;
7732 break;
7733
7734 case 'G': //"&GIF"
7735 SnapshotFormat=1;
7736 break;
7737
7738 case 'J': //"&JPG"
7739 SnapshotFormat=2;
7740 break;
7741
7742 case 'P': //"&PNG"
7743 SnapshotFormat=3;
7744 break;
7745
7746 case 'C': //"PC&X"
7747 SnapshotFormat=4;
7748 break;
7749
7750 case 'T': //"&TGA"
7751 SnapshotFormat=5;
7752 break;
7753
7754 case 'L': //"&LBM"
7755 SnapshotFormat=6;
7756 break;
7757 }
7758 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7759
7760 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7761 return D_O_K;
7762 }
7763
7764
7765 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7766 {
7767 PALETTE tmp;
7768
7769 for(int32_t i=0; i<256; i++)
7770 {
7771 tmp[i].r=r;
7772 tmp[i].g=g;
7773 tmp[i].b=b;
7774 }
7775
7776 fade_interpolate(src,tmp,dest,pos,from,to);
7777 }
7778
7779 52 void system_pal(bool force)
7780 {
7781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if(is_sys_pal && !force) return;
7782 52 is_sys_pal = true;
7783 52 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7784 52 hw_palette = &syspal;
7785 52 update_hw_pal = true;
7786 52 }
7787
7788 static uint32_t entered_sys_pal = 0;
7789 52 void enter_sys_pal()
7790 {
7791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if(is_sys_pal)
7792 {
7793 if(entered_sys_pal)
7794 ++entered_sys_pal;
7795 return;
7796 }
7797 52 sys_mouse();
7798 52 system_pal(true);
7799 52 ++entered_sys_pal;
7800 52 }
7801 52 void exit_sys_pal()
7802 {
7803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if(entered_sys_pal)
7804 {
7805
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if(!--entered_sys_pal)
7806 {
7807 52 game_pal();
7808 52 game_mouse();
7809 52 }
7810 52 }
7811 52 }
7812
7813 void switch_out_callback()
7814 {
7815 if (pause_in_background)
7816 {
7817 callback_switchin = 3;
7818 return;
7819 }
7820
7821 #ifdef _WIN32
7822 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
7823 return;
7824
7825
7826 paused_midi_pos = midi_pos;
7827 zc_stop_midi();
7828 midi_paused=true;
7829 midi_suspended = midissuspHALTED;
7830 #endif
7831 }
7832
7833 void switch_in_callback()
7834 {
7835 if(pause_in_background)
7836 {
7837 return;
7838 }
7839
7840 #ifdef _WIN32
7841 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
7842 return;
7843
7844 else
7845 {
7846 callback_switchin = 1;
7847 midi_suspended = midissuspRESUME;
7848 }
7849 #endif
7850 }
7851
7852 352 void game_pal()
7853 {
7854 352 is_sys_pal = false;
7855 352 entered_sys_pal = 0;
7856 352 hw_palette = &RAMpal;
7857 352 update_hw_pal = true;
7858 352 }
7859
7860 static char bar_str[] = "";
7861
7862 13 void music_pause()
7863 {
7864 //al_pause_duh(tmplayer);
7865 13 zcmusic_pause(zcmusic, ZCM_PAUSE);
7866 13 zc_midi_pause();
7867 13 midi_paused=true;
7868 13 }
7869
7870 void music_resume()
7871 {
7872 //al_resume_duh(tmplayer);
7873 zcmusic_pause(zcmusic, ZCM_RESUME);
7874 zc_midi_resume();
7875 midi_paused=false;
7876 }
7877
7878 6599 void music_stop()
7879 {
7880 //al_stop_duh(tmplayer);
7881 //unload_duh(tmusic);
7882 //tmusic=NULL;
7883 //tmplayer=NULL;
7884 6599 zcmusic_stop(zcmusic);
7885 6599 zcmusic_unload_file(zcmusic);
7886 6599 zc_stop_midi();
7887 6599 midi_paused=false;
7888 6599 currmidi=-1;
7889 6599 }
7890
7891 void System()
7892 {
7893 mouse_down=gui_mouse_b();
7894 music_pause();
7895 pause_all_sfx();
7896 MenuOpen = true;
7897 enter_sys_pal();
7898 // FONT *oldfont=font;
7899 // font=tfont;
7900
7901 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7902 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7903
7904 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7905 #if DEVLEVEL > 1
7906 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7907 #endif
7908 game_menu[3].flags =
7909 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7910 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7911 clear_keybuf();
7912
7913 DIALOG_PLAYER *p;
7914
7915 clear_bitmap(menu_bmp);
7916 oldscreen = screen;
7917 screen = menu_bmp;
7918
7919 p = init_dialog(system_dlg,-1);
7920
7921 // drop the menu on startup if menu button pressed
7922 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7923 simulate_keypress(KEY_G << 8);
7924
7925 do
7926 {
7927 if(close_button_quit)
7928 {
7929 close_button_quit = false;
7930 f_Quit(qEXIT);
7931 if(Quit) break;
7932 }
7933 rest(17);
7934
7935 if(mouse_down && !gui_mouse_b())
7936 mouse_down=0;
7937
7938 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
7939 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
7940 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
7941
7942 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7943 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7944 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7945 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7946 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7947 settings_menu[10].flags = NESquit?D_SELECTED:0;
7948 settings_menu[11].flags = volkeys?D_SELECTED:0;
7949
7950 window_menu[0].flags = DragAspect?D_SELECTED:0;
7951 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7952 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7953 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7954 window_menu[4].flags = stretchGame?D_SELECTED:0;
7955
7956 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7957 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
7958
7959 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7960 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7961 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7962
7963 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7964 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7965 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7966
7967 bool nocheat = (replay_is_replaying() || !Playing
7968 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7969 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7970 cheat_menu[0].flags = 0;
7971 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
7972 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7973 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7974 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7975 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7976 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7977 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7978 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7979 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7980
7981 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7982 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7983 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7984 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7985 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7986 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7987 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7988 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7989 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7990 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7991 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7992 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7993 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7994 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7995 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7996
7997 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7998 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7999
8000 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8001 (char *)"Disable recording new saves" :
8002 (char *)"Enable recording new saves";
8003 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8004 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8005 (char *)"Stop recording" :
8006 (char *)"Stop replaying";
8007 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8008 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8009 (char *)"Disable snapshot all frames" :
8010 (char *)"Enable snapshot all frames";
8011
8012 reset_snapshot_format_menu();
8013 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8014
8015 if(debug_enabled)
8016 {
8017 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8018 }
8019
8020 if(gui_mouse_b() && !mouse_down)
8021 break;
8022
8023 // press menu to drop the menu
8024 if(rMbtn())
8025 simulate_keypress(KEY_G << 8);
8026
8027 if(input_idle(true) > after_time())
8028 // run Screeen Saver
8029 {
8030 // Screen saver enabled for now.
8031 clear_keybuf();
8032 Matrix(ss_speed, ss_density, 0);
8033 system_pal();
8034 sys_mouse();
8035 broadcast_dialog_message(MSG_DRAW, 0);
8036 }
8037
8038 update_hw_screen();
8039 }
8040 while(update_dialog(p));
8041
8042 screen = oldscreen;
8043
8044 // font=oldfont;
8045 mouse_down=gui_mouse_b();
8046 shutdown_dialog(p);
8047 MenuOpen = false;
8048 if(Quit)
8049 {
8050 kill_sfx();
8051 music_stop();
8052 update_hw_screen();
8053 }
8054 else
8055 {
8056 music_resume();
8057 resume_all_sfx();
8058
8059 if(rc)
8060 ringcolor(false);
8061 }
8062 exit_sys_pal();
8063
8064 eat_buttons();
8065
8066 rc=false;
8067 clear_keybuf();
8068 // text_mode(0);
8069 }
8070
8071 39 void fix_dialogs()
8072 {
8073 39 jwin_center_dialog(about_dlg);
8074 39 jwin_center_dialog(gamepad_dlg);
8075 39 jwin_center_dialog(credits_dlg);
8076 39 jwin_center_dialog(gamemode_dlg);
8077 39 jwin_center_dialog(getnum_dlg);
8078 39 jwin_center_dialog(goto_dlg);
8079 39 jwin_center_dialog(keyboard_control_dlg);
8080 39 jwin_center_dialog(midi_dlg);
8081 39 jwin_center_dialog(quest_dlg);
8082 39 jwin_center_dialog(scrsaver_dlg);
8083 39 jwin_center_dialog(sound_dlg);
8084 39 jwin_center_dialog(triforce_dlg);
8085
8086 // digi_dp[1] += scrx;
8087 // digi_dp[2] += scry;
8088 // midi_dp[1] += scrx;
8089 // midi_dp[2] += scry;
8090 // pan_dp[1] += scrx;
8091 // pan_dp[2] += scry;
8092 // emus_dp[1] += scrx;
8093 // emus_dp[2] += scry;
8094 // buf_dp[1] += scrx;
8095 // buf_dp[2] += scry;
8096 // sfx_dp[1] += scrx;
8097 // sfx_dp[2] += scry;
8098 39 }
8099
8100 /*****************************/
8101 /**** Custom Sound System ****/
8102 /*****************************/
8103
8104 2901 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8105 {
8106
3/4
✓ Branch 0 taken 2643 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2901 times.
✗ Branch 3 not taken.
2901 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8107 }
8108
8109 // Run an NSF, or a MIDI if the NSF is missing somehow.
8110 106 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8111 {
8112 106 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8113
8114 // Found it
8115
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 38 times.
106 if(newzcmusic!=NULL)
8116 {
8117 68 zcmusic_stop(zcmusic);
8118 68 zcmusic_unload_file(zcmusic);
8119 68 zc_stop_midi();
8120
8121 68 zcmusic=newzcmusic;
8122 68 zcmusic_play(zcmusic, emusic_volume);
8123
8124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(track>0)
8125 68 zcmusic_change_track(zcmusic,track);
8126
8127 68 return true;
8128 }
8129
8130 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8131
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 else if(midi>-1000)
8132 jukebox(midi);
8133
8134 38 return false;
8135 106 }
8136
8137 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8138 {
8139 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8140 // Found it
8141 if(newzcmusic!=NULL)
8142 {
8143 zcmusic_stop(zcmusic);
8144 zcmusic_unload_file(zcmusic);
8145 zc_stop_midi();
8146
8147 zcmusic=newzcmusic;
8148 zcmusic_play(zcmusic, emusic_volume);
8149
8150 if(track>0)
8151 zcmusic_change_track(zcmusic,track);
8152
8153 return true;
8154 }
8155
8156 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8157 else if(midi>-1000)
8158 jukebox(midi);
8159
8160 return false;
8161 }
8162
8163 int32_t get_zcmusicpos()
8164 {
8165 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8166 return debugtracething;
8167 return 0;
8168 }
8169
8170 void set_zcmusicpos(int32_t position)
8171 {
8172 zcmusic_set_curpos(zcmusic, position);
8173 }
8174
8175 void set_zcmusicspeed(int32_t speed)
8176 {
8177 int32_t newspeed = vbound(speed, 0, 10000);
8178 zcmusic_set_speed(zcmusic, newspeed);
8179 }
8180
8181 1431 void jukebox(int32_t index,int32_t loop)
8182 {
8183 1431 music_stop();
8184
8185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1431 times.
1431 if(index<0) index=MAXMIDIS-1;
8186
8187
1/2
✓ Branch 0 taken 1431 times.
✗ Branch 1 not taken.
1431 if(index>=MAXMIDIS) index=0;
8188
8189 1431 music_stop();
8190
8191 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8192 // stuck notes when a song stops. This fixes it.
8193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1431 times.
1431 if(strcmp(midi_driver->name, "DIGMID")==0)
8194 zc_set_volume(0, 0);
8195
8196 1431 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8197 1431 zc_play_midi((MIDI*)tunes[index].data,loop);
8198
8199
2/2
✓ Branch 0 taken 1029 times.
✓ Branch 1 taken 402 times.
1431 if(tunes[index].start>0)
8200 402 zc_midi_seek(tunes[index].start);
8201
8202 1431 midi_loop_start = tunes[index].loop_start;
8203 1431 midi_loop_end = tunes[index].loop_end;
8204
8205 1431 currmidi=index;
8206 1431 master_volume(digi_volume,midi_volume);
8207 1431 midi_paused=false;
8208 1431 }
8209
8210 11408 void jukebox(int32_t index)
8211 {
8212
1/2
✓ Branch 0 taken 11408 times.
✗ Branch 1 not taken.
11408 if(index<0) index=MAXMIDIS-1;
8213
8214
1/2
✓ Branch 0 taken 11408 times.
✗ Branch 1 not taken.
11408 if(index>=MAXMIDIS) index=0;
8215
8216 // do nothing if it's already playing
8217
3/4
✓ Branch 0 taken 9977 times.
✓ Branch 1 taken 1431 times.
✓ Branch 2 taken 9977 times.
✗ Branch 3 not taken.
11408 if(index==currmidi && midi_pos>=0)
8218 {
8219 9977 midi_paused=false;
8220 9977 return;
8221 }
8222
8223 1431 jukebox(index,tunes[index].loop);
8224 11408 }
8225
8226 12749 void play_DmapMusic()
8227 {
8228 static char tfile[2048];
8229 static int32_t ttrack=0;
8230 12749 bool domidi=false;
8231
8232
2/2
✓ Branch 0 taken 1462 times.
✓ Branch 1 taken 11287 times.
12749 if(DMaps[currdmap].tmusic[0]!=0)
8233 {
8234
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1847 if(zcmusic==NULL ||
8235
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8236
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8237 {
8238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1077 times.
1077 if(zcmusic != NULL)
8239 {
8240 zcmusic_stop(zcmusic);
8241 zcmusic_unload_file(zcmusic);
8242 zcmusic = NULL;
8243 }
8244
8245 1077 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8246
8247
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 990 times.
1077 if(zcmusic!=NULL)
8248 {
8249 87 zc_stop_midi();
8250 87 strcpy(tfile,DMaps[currdmap].tmusic);
8251 87 zcmusic_play(zcmusic, emusic_volume);
8252 87 int32_t temptracks=0;
8253 87 temptracks=zcmusic_get_tracks(zcmusic);
8254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 temptracks=(temptracks<2)?1:temptracks;
8255 87 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8256 87 zcmusic_change_track(zcmusic,ttrack);
8257 87 }
8258 else
8259 {
8260 990 tfile[0] = 0;
8261 990 domidi=true;
8262 }
8263 1077 }
8264 1462 }
8265 else
8266 {
8267 11287 domidi=true;
8268 }
8269
8270
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 12277 times.
12749 if(domidi)
8271 {
8272 12277 int32_t m=DMaps[currdmap].midi;
8273
8274
3/4
✓ Branch 0 taken 11884 times.
✓ Branch 1 taken 374 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
12277 switch(m)
8275 {
8276 case 1:
8277 374 jukebox(ZC_MIDI_OVERWORLD);
8278 374 break;
8279
8280 case 2:
8281 19 jukebox(ZC_MIDI_DUNGEON);
8282 19 break;
8283
8284 case 3:
8285 jukebox(ZC_MIDI_LEVEL9);
8286 break;
8287
8288 default:
8289
3/4
✓ Branch 0 taken 10843 times.
✓ Branch 1 taken 1041 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10843 times.
11884 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8290 10843 jukebox(m+MIDIOFFSET_DMAP);
8291 else
8292 1041 music_stop();
8293 11884 }
8294 12277 }
8295 12749 }
8296
8297 12787 void playLevelMusic()
8298 {
8299 12787 int32_t m=tmpscr->screen_midi;
8300
8301
3/6
✓ Branch 0 taken 12733 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
12787 switch(m)
8302 {
8303 case -2:
8304 13 music_stop();
8305 13 break;
8306
8307 case -1:
8308 12733 play_DmapMusic();
8309 12733 break;
8310
8311 case 1:
8312 jukebox(ZC_MIDI_OVERWORLD);
8313 break;
8314
8315 case 2:
8316 jukebox(ZC_MIDI_DUNGEON);
8317 break;
8318
8319 case 3:
8320 jukebox(ZC_MIDI_LEVEL9);
8321 break;
8322
8323 default:
8324
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8325 41 jukebox(m+MIDIOFFSET_MAPSCR);
8326 else
8327 music_stop();
8328 41 }
8329 12787 }
8330
8331 1470 void master_volume(int32_t dv,int32_t mv)
8332 {
8333
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1470 times.
✓ Branch 2 taken 1470 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1470 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1470 times.
✗ Branch 7 not taken.
1470 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8334
8335
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1470 times.
✓ Branch 2 taken 1470 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1470 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1470 times.
✗ Branch 7 not taken.
1470 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8336
8337
6/6
✓ Branch 0 taken 1428 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 1468 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1426 times.
✓ Branch 5 taken 42 times.
1470 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8338 1470 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8339 1470 }
8340
8341 /*****************/
8342 /***** SFX *****/
8343 /*****************/
8344
8345 // array of voices, one for each sfx sample in the data file
8346 // 0+ = voice #
8347 // -1 = voice not allocated
8348 39 void Z_init_sound()
8349 {
8350
2/2
✓ Branch 0 taken 9984 times.
✓ Branch 1 taken 39 times.
10023 for(int32_t i=0; i<WAV_COUNT; i++)
8351 9984 sfx_voice[i]=-1;
8352
8353
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 39 times.
312 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8354 273 tunes[i].data = (MIDI*)mididata[i].dat;
8355
8356
2/2
✓ Branch 0 taken 9828 times.
✓ Branch 1 taken 39 times.
9867 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8357 9828 tunes[ZC_MIDI_COUNT+j].data=NULL;
8358
8359 39 master_volume(digi_volume,midi_volume);
8360 39 }
8361
8362 // returns number of voices currently allocated
8363 int32_t sfx_count()
8364 {
8365 int32_t c=0;
8366
8367 for(int32_t i=0; i<WAV_COUNT; i++)
8368 if(sfx_voice[i]!=-1)
8369 ++c;
8370
8371 return c;
8372 }
8373
8374 // clean up finished samples
8375 8070137 void sfx_cleanup()
8376 {
8377
2/2
✓ Branch 0 taken 2065955072 times.
✓ Branch 1 taken 8070137 times.
2074025209 for(int32_t i=0; i<WAV_COUNT; i++)
8378
3/4
✓ Branch 0 taken 633784 times.
✓ Branch 1 taken 2065321288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 633784 times.
2066588856 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8379 {
8380 633784 deallocate_voice(sfx_voice[i]);
8381 633784 sfx_voice[i]=-1;
8382 633784 }
8383 8070137 }
8384
8385 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8386 // if a voice is already allocated (and/or playing), then it just returns true
8387 // Returns true: voice is allocated
8388 // false: unsuccessful
8389 974416 bool sfx_init(int32_t index)
8390 {
8391 // check index
8392
3/4
✓ Branch 0 taken 702705 times.
✓ Branch 1 taken 271711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 702705 times.
974416 if(index<=0 || index>=WAV_COUNT)
8393 271711 return false;
8394
8395
2/2
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 633811 times.
702705 if(sfx_voice[index]==-1)
8396 {
8397
2/2
✓ Branch 0 taken 182177 times.
✓ Branch 1 taken 451634 times.
633811 if(sfxdat)
8398 {
8399
1/2
✓ Branch 0 taken 182177 times.
✗ Branch 1 not taken.
182177 if(index<Z35)
8400 {
8401 182177 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8402 182177 }
8403 else
8404 {
8405 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8406 }
8407 182177 }
8408 else
8409 {
8410 451634 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8411 }
8412
8413 633811 voice_set_volume(sfx_voice[index], sfx_volume);
8414 633811 }
8415
8416 702705 return sfx_voice[index] != -1;
8417 974416 }
8418
8419 // plays an sfx sample
8420 829949 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8421 {
8422
2/2
✓ Branch 0 taken 630945 times.
✓ Branch 1 taken 199004 times.
829949 if(!sfx_init(index))
8423 199004 return;
8424
8425 630945 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8426 630945 voice_set_pan(sfx_voice[index],pan);
8427
8428 630945 int32_t pos = voice_get_position(sfx_voice[index]);
8429
8430
2/2
✓ Branch 0 taken 298046 times.
✓ Branch 1 taken 332899 times.
630945 if(restart) voice_set_position(sfx_voice[index],0);
8431
8432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630945 times.
630945 if(pos<=0)
8433 630945 voice_start(sfx_voice[index]);
8434
8435
3/4
✓ Branch 0 taken 332899 times.
✓ Branch 1 taken 298046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 332899 times.
630945 if (restart && replay_is_debug())
8436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332899 times.
332899 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8437 829949 }
8438
8439 // true if sfx is allocated
8440 35890 bool sfx_allocated(int32_t index)
8441 {
8442
3/4
✓ Branch 0 taken 9407 times.
✓ Branch 1 taken 26483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9407 times.
35890 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8443 }
8444
8445 // start it (in loop mode) if it's not already playing,
8446 // otherwise adjust it to play in loop mode -DD
8447 144467 void cont_sfx(int32_t index)
8448 {
8449
2/2
✓ Branch 0 taken 72707 times.
✓ Branch 1 taken 71760 times.
144467 if(!sfx_init(index))
8450 {
8451 72707 return;
8452 }
8453
8454
1/2
✓ Branch 0 taken 71760 times.
✗ Branch 1 not taken.
71760 if(voice_get_position(sfx_voice[index])<=0)
8455 {
8456 71760 voice_set_position(sfx_voice[index],0);
8457 71760 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8458 71760 voice_start(sfx_voice[index]);
8459 71760 }
8460 else
8461 {
8462 adjust_sfx(index, 128, true);
8463 }
8464 144467 }
8465
8466 // adjust parameters while playing
8467 3961 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8468 {
8469
5/6
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2187 times.
3961 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8470 3947 return;
8471
8472 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8473 14 voice_set_pan(sfx_voice[index],pan);
8474 3961 }
8475
8476 // pauses a voice
8477 1651 void pause_sfx(int32_t index)
8478 {
8479
3/6
✓ Branch 0 taken 1651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1651 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1651 times.
1651 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8480 voice_stop(sfx_voice[index]);
8481 1651 }
8482
8483 // resumes a voice
8484 709 void resume_sfx(int32_t index)
8485 {
8486
3/6
✓ Branch 0 taken 709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 709 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 709 times.
709 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8487 voice_start(sfx_voice[index]);
8488 709 }
8489
8490 // pauses all active voices
8491 319 void pause_all_sfx()
8492 {
8493
2/2
✓ Branch 0 taken 81664 times.
✓ Branch 1 taken 319 times.
81983 for(int32_t i=0; i<WAV_COUNT; i++)
8494
2/2
✓ Branch 0 taken 81663 times.
✓ Branch 1 taken 1 times.
81665 if(sfx_voice[i]!=-1)
8495 1 voice_stop(sfx_voice[i]);
8496 319 }
8497
8498 // resumes all paused voices
8499 306 void resume_all_sfx()
8500 {
8501
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 306 times.
78642 for(int32_t i=0; i<WAV_COUNT; i++)
8502
1/2
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
78336 if(sfx_voice[i]!=-1)
8503 voice_start(sfx_voice[i]);
8504 306 }
8505
8506 // stops an sfx and deallocates the voice
8507 6465001 void stop_sfx(int32_t index)
8508 {
8509
3/4
✓ Branch 0 taken 5323800 times.
✓ Branch 1 taken 1141201 times.
✓ Branch 2 taken 5323800 times.
✗ Branch 3 not taken.
6465001 if(index<=0 || index>=WAV_COUNT)
8510 1141201 return;
8511
8512
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5323787 times.
5323800 if(sfx_voice[index]!=-1)
8513 {
8514 13 deallocate_voice(sfx_voice[index]);
8515 13 sfx_voice[index]=-1;
8516 13 }
8517 6465001 }
8518
8519 // Stops SFX played by Hero's item of the given family
8520 127218 void stop_item_sfx(int32_t family)
8521 {
8522 127218 int32_t id=current_item_id(family);
8523
8524
2/2
✓ Branch 0 taken 126752 times.
✓ Branch 1 taken 466 times.
127218 if(id<0)
8525 126752 return;
8526
8527 466 stop_sfx(itemsbuf[id].usesound);
8528 127218 }
8529
8530 2357 void kill_sfx()
8531 {
8532
2/2
✓ Branch 0 taken 603392 times.
✓ Branch 1 taken 2357 times.
605749 for(int32_t i=0; i<WAV_COUNT; i++)
8533
2/2
✓ Branch 0 taken 603378 times.
✓ Branch 1 taken 14 times.
603406 if(sfx_voice[i]!=-1)
8534 {
8535 14 deallocate_voice(sfx_voice[i]);
8536 14 sfx_voice[i]=-1;
8537 14 }
8538 2357 }
8539
8540 583997 int32_t pan(int32_t x)
8541 {
8542
1/4
✓ Branch 0 taken 583997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
583997 switch(pan_style)
8543 {
8544 case 0:
8545 return 128;
8546
8547 case 1:
8548 583997 return vbound((x>>1)+68,0,255);
8549
8550 case 2:
8551 return vbound(((x*3)>>2)+36,0,255);
8552 }
8553
8554 return vbound(x,0,255);
8555 583997 }
8556
8557 /*******************************/
8558 /******* Input Handlers ********/
8559 /*******************************/
8560
8561 21718664 bool joybtn(int32_t b)
8562 {
8563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21718664 times.
21718664 if(b == 0)
8564 return false;
8565
8566 21718664 return joy[joystick_index].button[b-1].b !=0;
8567 21718664 }
8568
8569 const char* joybtn_name(int32_t b)
8570 {
8571 if(b == 0)
8572 return "";
8573
8574 return joy[joystick_index].button[b-1].name;
8575 }
8576
8577 int32_t next_press_key();
8578
8579 int32_t next_press_btn()
8580 {
8581 clear_keybuf();
8582 /*bool b[joy[joystick_index].num_buttons+1];
8583
8584 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8585 b[i]=joybtn(i);*/
8586
8587 //first, we need to wait until they're pressing no buttons
8588 for(;;)
8589 {
8590 if(keypressed())
8591 {
8592 switch(readkey()>>8)
8593 {
8594 case KEY_ESC:
8595 return -1;
8596
8597 case KEY_SPACE:
8598 return 0;
8599 }
8600 }
8601
8602 poll_joystick();
8603 bool done = true;
8604
8605 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8606 {
8607 if(joybtn(i)) done = false;
8608 }
8609
8610 if(done) break;
8611 rest(1);
8612 }
8613
8614 //now, we need to wait for them to press any button
8615 for(;;)
8616 {
8617 if(keypressed())
8618 {
8619 switch(readkey()>>8)
8620 {
8621 case KEY_ESC:
8622 return -1;
8623
8624 case KEY_SPACE:
8625 return 0;
8626 }
8627 }
8628
8629 poll_joystick();
8630
8631 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8632 {
8633 if(joybtn(i)) return i;
8634 }
8635 rest(1);
8636 }
8637 }
8638
8639 1147936 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8640 {
8641
2/2
✓ Branch 0 taken 1143456 times.
✓ Branch 1 taken 4480 times.
1147936 bool ret = btn && !flag;
8642 1147936 flag = rawbtn;
8643
8644 1147936 return ret;
8645 }
8646 167001081 static bool rButton(bool &btn, bool &flag)
8647 {
8648
2/2
✓ Branch 0 taken 161125312 times.
✓ Branch 1 taken 5875769 times.
167001081 bool ret = btn && !flag;
8649 167001081 flag = btn;
8650
8651 167001081 return ret;
8652 }
8653 1648122 static bool rButtonPeek(bool btn, bool flag)
8654 {
8655
2/2
✓ Branch 0 taken 1535358 times.
✓ Branch 1 taken 112764 times.
1648122 if(!btn)
8656 {
8657 1535358 return false;
8658 }
8659
2/2
✓ Branch 0 taken 16429 times.
✓ Branch 1 taken 96335 times.
112764 else if(!flag)
8660 {
8661 16429 return true;
8662 }
8663
8664 96335 return false;
8665 1648122 }
8666
8667 // Updated only by keyboard/gamepad.
8668 // If in replay mode, this is set directly by the replay system.
8669 // This should never be read from directly - use control_state instead.
8670 bool raw_control_state[ZC_CONTROL_STATES];
8671
8672 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8673 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8674 // lasts until the next call to load_control_state.
8675 bool control_state[ZC_CONTROL_STATES];
8676 bool disable_control[ZC_CONTROL_STATES];
8677 bool drunk_toggle_state[11];
8678 bool disabledKeys[127];
8679 bool KeyInput[127];
8680 bool KeyPress[127];
8681
8682 bool key_current_frame[127];
8683 bool key_previous_frame[127];
8684
8685 static bool key_system[127];
8686 static bool key_system_previous[127];
8687 static bool key_system_press[127];
8688
8689 bool button_press[ZC_CONTROL_STATES];
8690 bool button_hold[ZC_CONTROL_STATES];
8691
8692 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8693 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8694 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8695 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8696 #define STICK_PRECISION 56 //define your own sensitivity
8697
8698 6802415 void load_control_state()
8699 {
8700 6802415 load_control_called_this_frame = true;
8701
8702
2/2
✓ Branch 0 taken 4150130 times.
✓ Branch 1 taken 2652285 times.
6802415 if (replay_version_check(8, 11))
8703 {
8704
2/2
✓ Branch 0 taken 47741130 times.
✓ Branch 1 taken 2652285 times.
50393415 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8705 47741130 down_control_states[i] = raw_control_state[i];
8706 2652285 }
8707
8708
1/2
✓ Branch 0 taken 6802415 times.
✗ Branch 1 not taken.
6802415 if (!replay_is_replaying())
8709 {
8710 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8711 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8712 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8713 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8714 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8715 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8716 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8717 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8718 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8719 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8720 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8721 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8722 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8723 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8724
8725 if(num_joysticks != 0)
8726 {
8727 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8728 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8729 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8730 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8731 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8732 }
8733 else
8734 {
8735 raw_control_state[14] = false;
8736 raw_control_state[15] = false;
8737 raw_control_state[16] = false;
8738 raw_control_state[17] = false;
8739 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8740 }
8741 bool did_bad_cutscene_btn = false;
8742 for(int q = 0; q < 18; ++q)
8743 if(raw_control_state[q] && !active_cutscene.can_button(q))
8744 {
8745 raw_control_state[q] = false;
8746 did_bad_cutscene_btn = true;
8747 }
8748 if(did_bad_cutscene_btn)
8749 active_cutscene.error();
8750 }
8751
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6802412 times.
6802415 if (replay_is_active())
8752 {
8753
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5787197 times.
6802412 if (replay_get_version() < 3)
8754 1015215 replay_poll();
8755
3/4
✓ Branch 0 taken 5787197 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4025822 times.
✓ Branch 3 taken 1761375 times.
5787197 else if (replay_is_replaying() && replay_get_version() < 6)
8756 1761375 replay_peek_input();
8757
3/4
✓ Branch 0 taken 4025822 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1373537 times.
✓ Branch 3 taken 2652285 times.
4025822 else if (replay_is_replaying() && replay_version_check(8, 11))
8758 2652285 replay_peek_input();
8759
2/2
✓ Branch 0 taken 5698122 times.
✓ Branch 1 taken 1104290 times.
6802412 if (replay_get_version() == 8)
8760 1104290 update_keys();
8761 6802412 }
8762
8763 // Some test replay files were made before a serious input bug was fixed, so instead
8764 // of re-doing them or tossing them out, just check for that zplay version.
8765
3/4
✓ Branch 0 taken 6802409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6680509 times.
6802415 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8766
2/2
✓ Branch 0 taken 6802409 times.
✓ Branch 1 taken 122443362 times.
129245771 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8767 {
8768 122443362 control_state[i] = raw_control_state[i];
8769
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 72956052 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
122443362 if (botched_input && !control_state[i])
8770 47077142 down_control_states[i] = false;
8771 122443362 }
8772
8773 6802409 button_press[0]=rButton(control_state[0],button_hold[0]);
8774 6802409 button_press[1]=rButton(control_state[1],button_hold[1]);
8775 6802409 button_press[2]=rButton(control_state[2],button_hold[2]);
8776 6802409 button_press[3]=rButton(control_state[3],button_hold[3]);
8777 6802409 button_press[4]=rButton(control_state[4],button_hold[4]);
8778 6802409 button_press[5]=rButton(control_state[5],button_hold[5]);
8779 6802409 button_press[6]=rButton(control_state[6],button_hold[6]);
8780 6802409 button_press[7]=rButton(control_state[7],button_hold[7]);
8781 6802409 button_press[8]=rButton(control_state[8],button_hold[8]);
8782 6802409 button_press[9]=rButton(control_state[9],button_hold[9]);
8783 6802409 button_press[10]=rButton(control_state[10],button_hold[10]);
8784 6802409 button_press[11]=rButton(control_state[11],button_hold[11]);
8785 6802409 button_press[12]=rButton(control_state[12],button_hold[12]);
8786 6802409 button_press[13]=rButton(control_state[13],button_hold[13]);
8787 6802409 button_press[14]=rButton(control_state[14],button_hold[14]);
8788 6802409 button_press[15]=rButton(control_state[15],button_hold[15]);
8789 6802409 button_press[16]=rButton(control_state[16],button_hold[16]);
8790 6802409 button_press[17]=rButton(control_state[17],button_hold[17]);
8791 6802409 }
8792
8793 // Returns true if any game key is pressed. This is needed because keypressed()
8794 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8795 35291737 bool zc_key_pressed()
8796 //may also need to use zc_getrawkey
8797 {
8798
7/10
✓ Branch 0 taken 28588961 times.
✓ Branch 1 taken 6702776 times.
✓ Branch 2 taken 6702776 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6702776 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5618589 times.
✓ Branch 7 taken 5618589 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2127845 times.
37419582 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8799
4/6
✓ Branch 0 taken 5618589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5618589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4254558 times.
✓ Branch 5 taken 4254558 times.
5618589 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8800
4/6
✓ Branch 0 taken 4254558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4254558 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2747132 times.
✓ Branch 5 taken 2747132 times.
4254558 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8801
4/6
✓ Branch 0 taken 2747132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2747132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2381223 times.
✓ Branch 5 taken 2381223 times.
2747132 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8802
1/2
✓ Branch 0 taken 2381223 times.
✗ Branch 1 not taken.
2381223 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8803
3/4
✓ Branch 0 taken 2265442 times.
✓ Branch 1 taken 115781 times.
✓ Branch 2 taken 2265442 times.
✗ Branch 3 not taken.
2381223 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8804
3/4
✓ Branch 0 taken 2157537 times.
✓ Branch 1 taken 107905 times.
✓ Branch 2 taken 2157537 times.
✗ Branch 3 not taken.
2265442 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8805
3/4
✓ Branch 0 taken 2143046 times.
✓ Branch 1 taken 14491 times.
✓ Branch 2 taken 2143046 times.
✗ Branch 3 not taken.
2157537 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8806
3/4
✓ Branch 0 taken 2130468 times.
✓ Branch 1 taken 12578 times.
✓ Branch 2 taken 2130468 times.
✗ Branch 3 not taken.
2143046 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8807
3/4
✓ Branch 0 taken 2128724 times.
✓ Branch 1 taken 1744 times.
✓ Branch 2 taken 2128724 times.
✗ Branch 3 not taken.
2130468 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8808
3/4
✓ Branch 0 taken 2128651 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 2128651 times.
✗ Branch 3 not taken.
2128724 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8809
3/4
✓ Branch 0 taken 2127864 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 2127864 times.
✗ Branch 3 not taken.
2128651 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8810
2/4
✓ Branch 0 taken 2127864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127864 times.
✗ Branch 3 not taken.
2127864 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8811
2/2
✓ Branch 0 taken 2127845 times.
✓ Branch 1 taken 19 times.
2127864 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8812 63166896 return true;
8813
8814 2127845 return false;
8815 8116819 }
8816
8817 133546839 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8818 {
8819 133546839 bool ret = false, drunkstate = false, rawret = false;;
8820 133546839 bool* flag = &down_control_states[btn];
8821
2/7
✓ Branch 0 taken 125421528 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 8125311 times.
133546839 switch(btn)
8822 {
8823 case btnF12:
8824 ret = zc_getkey(KEY_F12, ignoreDisable);
8825 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8826 eatEntirely = false;
8827 break;
8828 case btnF11:
8829 ret = zc_getkey(KEY_F11, ignoreDisable);
8830 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8831 eatEntirely = false;
8832 break;
8833 case btnF5:
8834 ret = zc_getkey(KEY_F5, ignoreDisable);
8835 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8836 eatEntirely = false;
8837 break;
8838 case btnQ:
8839 ret = zc_getkey(KEY_Q, ignoreDisable);
8840 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8841 eatEntirely = false;
8842 break;
8843 case btnI:
8844 ret = zc_getkey(KEY_I, ignoreDisable);
8845 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8846 eatEntirely = false;
8847 break;
8848 case btnM:
8849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8125311 times.
8125311 if(FFCore.kb_typing_mode) return false;
8850 8125311 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8851 8125311 eatEntirely = false;
8852 8125311 break;
8853 default: //control_state[] index
8854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125421528 times.
125421528 if(FFCore.kb_typing_mode) return false;
8855
5/6
✓ Branch 0 taken 124974341 times.
✓ Branch 1 taken 447187 times.
✓ Branch 2 taken 2045171 times.
✓ Branch 3 taken 122929170 times.
✓ Branch 4 taken 2045171 times.
✗ Branch 5 not taken.
125421528 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8856
2/2
✓ Branch 0 taken 6781717 times.
✓ Branch 1 taken 118639811 times.
125421528 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8857
4/4
✓ Branch 0 taken 113060311 times.
✓ Branch 1 taken 12361217 times.
✓ Branch 2 taken 5041 times.
✓ Branch 3 taken 12356176 times.
137782745 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8858 125421528 rawret = raw_control_state[btn];
8859 125421528 }
8860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133546839 times.
133546839 assert(flag);
8861
2/2
✓ Branch 0 taken 86193062 times.
✓ Branch 1 taken 47353777 times.
133546839 if(press)
8862 {
8863
2/2
✓ Branch 0 taken 1648122 times.
✓ Branch 1 taken 45705655 times.
47353777 if(peek)
8864 1648122 ret = rButtonPeek(ret, *flag);
8865
2/2
✓ Branch 0 taken 1147936 times.
✓ Branch 1 taken 44557719 times.
45705655 else if(get_bit(quest_rules, qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8866 1147936 else ret = rButton(ret, *flag, rawret);
8867 47353777 }
8868
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133546839 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133546839 if(eatEntirely && ret) control_state[btn] = false;
8869
3/4
✓ Branch 0 taken 101057317 times.
✓ Branch 1 taken 32489522 times.
✓ Branch 2 taken 101057317 times.
✗ Branch 3 not taken.
133546839 if(drunk && drunkstate) ret = !ret;
8870 133546839 return ret;
8871 133546839 }
8872
8873 6554561 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8874 {
8875 6554561 byte ret = 0;
8876
2/2
✓ Branch 0 taken 4904349 times.
✓ Branch 1 taken 1650212 times.
6554561 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8877
2/2
✓ Branch 0 taken 6553999 times.
✓ Branch 1 taken 562 times.
6554561 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8878
2/2
✓ Branch 0 taken 6554124 times.
✓ Branch 1 taken 437 times.
6554561 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8879
2/2
✓ Branch 0 taken 6554124 times.
✓ Branch 1 taken 437 times.
6554561 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8880
2/2
✓ Branch 0 taken 6554124 times.
✓ Branch 1 taken 437 times.
6554561 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8881
2/2
✓ Branch 0 taken 6554124 times.
✓ Branch 1 taken 437 times.
6554561 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8882
2/2
✓ Branch 0 taken 6554124 times.
✓ Branch 1 taken 437 times.
6554561 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8883
2/2
✓ Branch 0 taken 6554124 times.
✓ Branch 1 taken 437 times.
6554561 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8884 6554561 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8885 }
8886
8887 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8888 {
8889 1114 return intbtn&vals;
8890 }
8891
8892 1575595 bool Up()
8893 {
8894 1575595 return getInput(btnUp);
8895 }
8896 99566 bool Down()
8897 {
8898 99566 return getInput(btnDown);
8899 }
8900 190762 bool Left()
8901 {
8902 190762 return getInput(btnLeft);
8903 }
8904 213766 bool Right()
8905 {
8906 213766 return getInput(btnRight);
8907 }
8908 112761 bool cAbtn()
8909 {
8910 112761 return getInput(btnA);
8911 }
8912 1333347 bool cBbtn()
8913 {
8914 1333347 return getInput(btnB);
8915 }
8916 bool cSbtn()
8917 {
8918 return getInput(btnS);
8919 }
8920 46682 bool cLbtn()
8921 {
8922 46682 return getInput(btnL);
8923 }
8924 46682 bool cRbtn()
8925 {
8926 46682 return getInput(btnR);
8927 }
8928 bool cPbtn()
8929 {
8930 return getInput(btnP);
8931 }
8932 bool cEx1btn()
8933 {
8934 return getInput(btnEx1);
8935 }
8936 bool cEx2btn()
8937 {
8938 return getInput(btnEx2);
8939 }
8940 bool cEx3btn()
8941 {
8942 return getInput(btnEx3);
8943 }
8944 bool cEx4btn()
8945 {
8946 return getInput(btnEx4);
8947 }
8948 bool AxisUp()
8949 {
8950 return getInput(btnAxisUp);
8951 }
8952 bool AxisDown()
8953 {
8954 return getInput(btnAxisDown);
8955 }
8956 bool AxisLeft()
8957 {
8958 return getInput(btnAxisLeft);
8959 }
8960 bool AxisRight()
8961 {
8962 return getInput(btnAxisRight);
8963 }
8964
8965 bool cMbtn()
8966 {
8967 return getInput(btnM);
8968 }
8969 bool cF12()
8970 {
8971 return getInput(btnF12);
8972 }
8973 bool cF11()
8974 {
8975 return getInput(btnF11);
8976 }
8977 bool cF5()
8978 {
8979 return getInput(btnF5);
8980 }
8981 bool cQ()
8982 {
8983 return getInput(btnQ);
8984 }
8985 bool cI()
8986 {
8987 return getInput(btnI);
8988 }
8989
8990 127703 bool rUp()
8991 {
8992 127703 return getInput(btnUp, true);
8993 }
8994 127609 bool rDown()
8995 {
8996 127609 return getInput(btnDown, true);
8997 }
8998 127557 bool rLeft()
8999 {
9000 127557 return getInput(btnLeft, true);
9001 }
9002 127093 bool rRight()
9003 {
9004 127093 return getInput(btnRight, true);
9005 }
9006 2987 bool rAbtn()
9007 {
9008 2987 return getInput(btnA, true);
9009 }
9010 128823 bool rBbtn()
9011 {
9012 128823 return getInput(btnB, true);
9013 }
9014 6538042 bool rSbtn()
9015 {
9016 6538042 return getInput(btnS, true);
9017 }
9018 8116819 bool rMbtn()
9019 {
9020 8116819 return getInput(btnM, true);
9021 }
9022 126885 bool rLbtn()
9023 {
9024 126885 return getInput(btnL, true);
9025 }
9026 126880 bool rRbtn()
9027 {
9028 126880 return getInput(btnR, true);
9029 }
9030 6455214 bool rPbtn()
9031 {
9032 6455214 return getInput(btnP, true);
9033 }
9034 bool rEx1btn()
9035 {
9036 return getInput(btnEx1, true);
9037 }
9038 bool rEx2btn()
9039 {
9040 return getInput(btnEx2, true);
9041 }
9042 137531 bool rEx3btn()
9043 {
9044 137531 return getInput(btnEx3, true);
9045 }
9046 137531 bool rEx4btn()
9047 {
9048 137531 return getInput(btnEx4, true);
9049 }
9050 bool rAxisUp()
9051 {
9052 return getInput(btnAxisUp, true);
9053 }
9054 bool rAxisDown()
9055 {
9056 return getInput(btnAxisDown, true);
9057 }
9058 bool rAxisLeft()
9059 {
9060 return getInput(btnAxisLeft, true);
9061 }
9062 bool rAxisRight()
9063 {
9064 return getInput(btnAxisRight, true);
9065 }
9066
9067 bool rF11()
9068 {
9069 return getInput(btnF11, true);
9070 }
9071 bool rQ()
9072 {
9073 return getInput(btnQ, true);
9074 }
9075 bool rI()
9076 {
9077 return getInput(btnI, true);
9078 }
9079
9080 16363222 bool DrunkUp()
9081 {
9082 16363222 return getInput(btnUp, false, true);
9083 }
9084 15237854 bool DrunkDown()
9085 {
9086 15237854 return getInput(btnDown, false, true);
9087 }
9088 9585171 bool DrunkLeft()
9089 {
9090 9585171 return getInput(btnLeft, false, true);
9091 }
9092 8321527 bool DrunkRight()
9093 {
9094 8321527 return getInput(btnRight, false, true);
9095 }
9096 7121837 bool DrunkcAbtn()
9097 {
9098 7121837 return getInput(btnA, false, true);
9099 }
9100 6993890 bool DrunkcBbtn()
9101 {
9102 6993890 return getInput(btnB, false, true);
9103 }
9104 6408186 bool DrunkcEx1btn()
9105 {
9106 6408186 return getInput(btnEx1, false, true);
9107 }
9108 6408206 bool DrunkcEx2btn()
9109 {
9110 6408206 return getInput(btnEx2, false, true);
9111 }
9112 bool DrunkcSbtn()
9113 {
9114 return getInput(btnS, false, true);
9115 }
9116 bool DrunkcMbtn()
9117 {
9118 return getInput(btnM, false, true);
9119 }
9120 bool DrunkcLbtn()
9121 {
9122 return getInput(btnL, false, true);
9123 }
9124 bool DrunkcRbtn()
9125 {
9126 return getInput(btnR, false, true);
9127 }
9128 bool DrunkcPbtn()
9129 {
9130 return getInput(btnP, false, true);
9131 }
9132
9133 bool DrunkrUp()
9134 {
9135 return getInput(btnUp, true, true);
9136 }
9137 bool DrunkrDown()
9138 {
9139 return getInput(btnDown, true, true);
9140 }
9141 bool DrunkrLeft()
9142 {
9143 return getInput(btnLeft, true, true);
9144 }
9145 bool DrunkrRight()
9146 {
9147 return getInput(btnRight, true, true);
9148 }
9149 5366617 bool DrunkrAbtn()
9150 {
9151 5366617 return getInput(btnA, true, true);
9152 }
9153 5382226 bool DrunkrBbtn()
9154 {
9155 5382226 return getInput(btnB, true, true);
9156 }
9157 71669 bool DrunkrEx1btn()
9158 {
9159 71669 return getInput(btnEx1, true, true);
9160 }
9161 71662 bool DrunkrEx2btn()
9162 {
9163 71662 return getInput(btnEx2, true, true);
9164 }
9165 bool DrunkrEx3btn()
9166 {
9167 return getInput(btnEx3, true, true);
9168 }
9169 bool DrunkrEx4btn()
9170 {
9171 return getInput(btnEx4, true, true);
9172 }
9173 bool DrunkrSbtn()
9174 {
9175 return getInput(btnS, true, true);
9176 }
9177 bool DrunkrMbtn()
9178 {
9179 return getInput(btnM, true, true);
9180 }
9181 6037618 bool DrunkrLbtn()
9182 {
9183 6037618 return getInput(btnL, true, true);
9184 }
9185 6034236 bool DrunkrRbtn()
9186 {
9187 6034236 return getInput(btnR, true, true);
9188 }
9189 bool DrunkrPbtn()
9190 {
9191 return getInput(btnP, true, true);
9192 }
9193
9194 8492 void eat_buttons()
9195 {
9196 8492 getInput(btnA, true, false, true);
9197 8492 getInput(btnB, true, false, true);
9198 8492 getInput(btnS, true, false, true);
9199 8492 getInput(btnM, true, false, true);
9200 8492 getInput(btnL, true, false, true);
9201 8492 getInput(btnR, true, false, true);
9202 8492 getInput(btnP, true, false, true);
9203 8492 getInput(btnEx1, true, false, true);
9204 8492 getInput(btnEx2, true, false, true);
9205 8492 getInput(btnEx3, true, false, true);
9206 8492 getInput(btnEx4, true, false, true);
9207 8492 }
9208
9209 // Is true for the _first frame_ of a key press.
9210 // But! it is possible that a script manually sets the value of KeyPress,
9211 // in which case it will be restored to the "true" value based on `key_current_frame`
9212 // and `key_previous_frame` on the next frame.
9213 13 bool zc_readkey(int32_t k, bool ignoreDisable)
9214 {
9215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(ignoreDisable) return KeyPress[k];
9216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 switch(k)
9217 {
9218 case KEY_F7:
9219 case KEY_F8:
9220 case KEY_F9:
9221 return KeyPress[k];
9222
9223 default:
9224
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 return KeyPress[k] && !disabledKeys[k];
9225 }
9226 13 }
9227
9228 // Is true for _every frame_ a key is held down.
9229 // But! it is possible that a script manually sets the value of KeyInput,
9230 // in which case it will be restored to the "true" value based on `key_current_frame`
9231 // on the next frame.
9232 bool zc_getkey(int32_t k, bool ignoreDisable)
9233 {
9234 if(ignoreDisable) return KeyInput[k];
9235 switch(k)
9236 {
9237 case KEY_F7:
9238 case KEY_F8:
9239 case KEY_F9:
9240 return KeyInput[k];
9241
9242 default:
9243 return KeyInput[k] && !disabledKeys[k];
9244 }
9245 }
9246
9247 // Reads (and then clears) the current frame key state directly.
9248 // Scripts can also modify `key_current_frame`.
9249 198 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9250 {
9251
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 196 times.
198 if(zc_getrawkey(k, ignoreDisable))
9252 {
9253 2 _key[k]=key[k]=key_current_frame[k]=0;
9254 2 return true;
9255 }
9256 196 _key[k]=key[k]=key_current_frame[k]=0;
9257 196 return false;
9258 198 }
9259
9260 // Reads the current frame key state directly.
9261 // Scripts can also modify `key_current_frame`.
9262 55156202 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9263 {
9264
2/2
✓ Branch 0 taken 47039357 times.
✓ Branch 1 taken 8116845 times.
55156202 if(ignoreDisable) return key_current_frame[k];
9265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116845 times.
8116845 switch(k)
9266 {
9267 case KEY_F7:
9268 case KEY_F8:
9269 case KEY_F9:
9270 return key_current_frame[k];
9271
9272 default:
9273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8116845 times.
8116845 return key_current_frame[k] && !disabledKeys[k];
9274 }
9275 55156202 }
9276
9277 // Only used for a handful of keys, like tilde and Function keys.
9278 // This state is never read within the game.
9279 // It exists so that all keyboard input still functions during replay,
9280 // without inadvertently doing things like toggling throttling if the player
9281 // presses ~
9282 16233734 bool zc_get_system_key(int32_t k)
9283 {
9284 16233734 return key_system[k];
9285 }
9286
9287 // True for the _first_ frame of a key press.
9288 73051371 bool zc_read_system_key(int32_t k)
9289 {
9290 73051371 return key_system_press[k];
9291 }
9292
9293 1030836013 bool is_system_key(int32_t k)
9294 {
9295
2/2
✓ Branch 0 taken 957784642 times.
✓ Branch 1 taken 73051371 times.
1030836013 switch (k)
9296 {
9297 case KEY_BACKQUOTE:
9298 case KEY_CLOSEBRACE:
9299 case KEY_END:
9300 case KEY_HOME:
9301 case KEY_OPENBRACE:
9302 case KEY_PGDN:
9303 case KEY_PGUP:
9304 case KEY_TAB:
9305 case KEY_TILDE:
9306 73051371 return true;
9307 }
9308 957784642 return is_Fkey(k);
9309 1030836013 }
9310
9311 8116819 void update_system_keys()
9312 {
9313
2/2
✓ Branch 0 taken 1030836013 times.
✓ Branch 1 taken 8116819 times.
1038952832 for (int32_t q = 0; q < 127; ++q)
9314 {
9315
2/2
✓ Branch 0 taken 170453199 times.
✓ Branch 1 taken 860382814 times.
1030836013 if (!is_system_key(q))
9316 860382814 continue;
9317
9318 170453199 key_system[q] = key[q];
9319
1/2
✓ Branch 0 taken 170453199 times.
✗ Branch 1 not taken.
170453199 key_system_press[q] = key_system[q] && !key_system_previous[q];
9320 170453199 key_system_previous[q] = key_system[q];
9321 170453199 }
9322 8116819 }
9323
9324 9221109 void update_keys()
9325 {
9326
2/2
✓ Branch 0 taken 1171080843 times.
✓ Branch 1 taken 9221109 times.
1180301952 for (int32_t q = 0; q < 127; ++q)
9327 {
9328 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9329
1/2
✓ Branch 0 taken 1171080843 times.
✗ Branch 1 not taken.
1171080843 if (!replay_is_replaying())
9330 key_current_frame[q] = key[q];
9331
9332
2/2
✓ Branch 0 taken 1162434127 times.
✓ Branch 1 taken 8646716 times.
1171080843 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9333 1171080843 KeyInput[q] = key_current_frame[q];
9334 1171080843 key_previous_frame[q] = key_current_frame[q];
9335 1171080843 }
9336 9221109 }
9337
9338 bool zc_disablekey(int32_t k, bool val)
9339 {
9340 switch(k)
9341 {
9342 case KEY_F7:
9343 case KEY_F8:
9344 case KEY_F9:
9345 return false;
9346
9347 default:
9348 disabledKeys[k] = val;
9349 return true;
9350 }
9351 }
9352
9353 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9354 {
9355 timer=timer;
9356 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9357 }
9358